Skip to content

Commit 003e902

Browse files
authored
Merge pull request #8 from DnyaneshwarWagh/Swift-4.2
Codebase updated for Swift-4.2
2 parents cd7da3a + 6d2e1f4 commit 003e902

17 files changed

+1493
-1447
lines changed

ReplaceAnimation.xcodeproj/project.pbxproj

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,11 +240,12 @@
240240
isa = PBXProject;
241241
attributes = {
242242
LastSwiftUpdateCheck = 0720;
243-
LastUpgradeCheck = 0720;
243+
LastUpgradeCheck = 1000;
244244
ORGANIZATIONNAME = "Alexander Hüllmandel";
245245
TargetAttributes = {
246246
2DB510121C865DDC00D6F36E = {
247247
CreatedOnToolsVersion = 7.2.1;
248+
ProvisioningStyle = Manual;
248249
};
249250
2DB510261C865DDC00D6F36E = {
250251
CreatedOnToolsVersion = 7.2.1;
@@ -384,13 +385,23 @@
384385
CLANG_CXX_LIBRARY = "libc++";
385386
CLANG_ENABLE_MODULES = YES;
386387
CLANG_ENABLE_OBJC_ARC = YES;
388+
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
387389
CLANG_WARN_BOOL_CONVERSION = YES;
390+
CLANG_WARN_COMMA = YES;
388391
CLANG_WARN_CONSTANT_CONVERSION = YES;
392+
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
389393
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
390394
CLANG_WARN_EMPTY_BODY = YES;
391395
CLANG_WARN_ENUM_CONVERSION = YES;
396+
CLANG_WARN_INFINITE_RECURSION = YES;
392397
CLANG_WARN_INT_CONVERSION = YES;
398+
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
399+
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
400+
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
393401
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
402+
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
403+
CLANG_WARN_STRICT_PROTOTYPES = YES;
404+
CLANG_WARN_SUSPICIOUS_MOVE = YES;
394405
CLANG_WARN_UNREACHABLE_CODE = YES;
395406
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
396407
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
@@ -429,13 +440,23 @@
429440
CLANG_CXX_LIBRARY = "libc++";
430441
CLANG_ENABLE_MODULES = YES;
431442
CLANG_ENABLE_OBJC_ARC = YES;
443+
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
432444
CLANG_WARN_BOOL_CONVERSION = YES;
445+
CLANG_WARN_COMMA = YES;
433446
CLANG_WARN_CONSTANT_CONVERSION = YES;
447+
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
434448
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
435449
CLANG_WARN_EMPTY_BODY = YES;
436450
CLANG_WARN_ENUM_CONVERSION = YES;
451+
CLANG_WARN_INFINITE_RECURSION = YES;
437452
CLANG_WARN_INT_CONVERSION = YES;
453+
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
454+
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
455+
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
438456
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
457+
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
458+
CLANG_WARN_STRICT_PROTOTYPES = YES;
459+
CLANG_WARN_SUSPICIOUS_MOVE = YES;
439460
CLANG_WARN_UNREACHABLE_CODE = YES;
440461
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
441462
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
@@ -454,6 +475,7 @@
454475
IPHONEOS_DEPLOYMENT_TARGET = 9.2;
455476
MTL_ENABLE_DEBUG_INFO = NO;
456477
SDKROOT = iphoneos;
478+
SWIFT_COMPILATION_MODE = wholemodule;
457479
TARGETED_DEVICE_FAMILY = "1,2";
458480
VALIDATE_PRODUCT = YES;
459481
};
@@ -463,21 +485,29 @@
463485
isa = XCBuildConfiguration;
464486
buildSettings = {
465487
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
488+
CODE_SIGN_STYLE = Manual;
489+
DEVELOPMENT_TEAM = "";
466490
INFOPLIST_FILE = ReplaceAnimation/Info.plist;
467491
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
468492
PRODUCT_BUNDLE_IDENTIFIER = fruitcode.ReplaceAnimation;
469493
PRODUCT_NAME = "$(TARGET_NAME)";
494+
PROVISIONING_PROFILE_SPECIFIER = "";
495+
SWIFT_VERSION = 4.2;
470496
};
471497
name = Debug;
472498
};
473499
2DB5103D1C865DDC00D6F36E /* Release */ = {
474500
isa = XCBuildConfiguration;
475501
buildSettings = {
476502
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
503+
CODE_SIGN_STYLE = Manual;
504+
DEVELOPMENT_TEAM = "";
477505
INFOPLIST_FILE = ReplaceAnimation/Info.plist;
478506
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
479507
PRODUCT_BUNDLE_IDENTIFIER = fruitcode.ReplaceAnimation;
480508
PRODUCT_NAME = "$(TARGET_NAME)";
509+
PROVISIONING_PROFILE_SPECIFIER = "";
510+
SWIFT_VERSION = 4.2;
481511
};
482512
name = Release;
483513
};

ReplaceAnimation/AppDelegate.swift

Lines changed: 32 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -10,37 +10,36 @@ import UIKit
1010

1111
@UIApplicationMain
1212
class AppDelegate: UIResponder, UIApplicationDelegate {
13-
14-
var window: UIWindow?
15-
16-
17-
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
18-
// Override point for customization after application launch.
19-
return true
20-
}
21-
22-
func applicationWillResignActive(application: UIApplication) {
23-
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
24-
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
25-
}
26-
27-
func applicationDidEnterBackground(application: UIApplication) {
28-
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
29-
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
30-
}
31-
32-
func applicationWillEnterForeground(application: UIApplication) {
33-
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
34-
}
35-
36-
func applicationDidBecomeActive(application: UIApplication) {
37-
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
38-
}
39-
40-
func applicationWillTerminate(application: UIApplication) {
41-
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
42-
}
43-
44-
13+
14+
var window: UIWindow?
15+
16+
17+
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
18+
// Override point for customization after application launch.
19+
return true
20+
}
21+
22+
func applicationWillResignActive(_ application: UIApplication) {
23+
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
24+
// Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
25+
}
26+
27+
func applicationDidEnterBackground(_ application: UIApplication) {
28+
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
29+
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
30+
}
31+
32+
func applicationWillEnterForeground(_ application: UIApplication) {
33+
// Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
34+
}
35+
36+
func applicationDidBecomeActive(_ application: UIApplication) {
37+
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
38+
}
39+
40+
func applicationWillTerminate(_ application: UIApplication) {
41+
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
42+
}
43+
44+
4545
}
46-

ReplaceAnimation/CollectionViewCell.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99
import UIKit
1010

1111
class CollectionViewCell: UICollectionViewCell {
12-
@IBOutlet weak var leftImage: UIImageView!
13-
@IBOutlet weak var leftLabel: UILabel!
14-
@IBOutlet weak var titleLabel: UILabel!
15-
@IBOutlet weak var subtitleLabel: UILabel!
16-
12+
@IBOutlet weak var leftImage: UIImageView!
13+
@IBOutlet weak var leftLabel: UILabel!
14+
@IBOutlet weak var titleLabel: UILabel!
15+
@IBOutlet weak var subtitleLabel: UILabel!
16+
1717
override func awakeFromNib() {
1818
super.awakeFromNib()
1919
// Initialization code
2020
}
21-
21+
2222
}

ReplaceAnimation/CollectionViewCell.xib

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="9532" systemVersion="15D21" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES">
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14313.18" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
3+
<device id="retina4_7" orientation="portrait">
4+
<adaptation id="fullscreen"/>
5+
</device>
36
<dependencies>
47
<deployment identifier="iOS"/>
5-
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9530"/>
6-
<capability name="Aspect ratio constraints" minToolsVersion="5.1"/>
7-
<capability name="Constraints with non-1.0 multipliers" minToolsVersion="5.1"/>
8+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14283.14"/>
9+
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
810
</dependencies>
911
<objects>
1012
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
@@ -14,6 +16,7 @@
1416
<autoresizingMask key="autoresizingMask"/>
1517
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center">
1618
<rect key="frame" x="0.0" y="0.0" width="487" height="58"/>
19+
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
1720
<subviews>
1821
<imageView hidden="YES" userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="VA5-fl-7N2">
1922
<rect key="frame" x="16" y="6" width="46.5" height="46"/>
@@ -22,9 +25,9 @@
2225
</constraints>
2326
</imageView>
2427
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Subtitle" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumFontSize="9" translatesAutoresizingMaskIntoConstraints="NO" id="FcI-2x-Q4j">
25-
<rect key="frame" x="77" y="33" width="363" height="19.5"/>
28+
<rect key="frame" x="77.5" y="32.5" width="362.5" height="19.5"/>
2629
<fontDescription key="fontDescription" type="system" pointSize="16"/>
27-
<color key="textColor" white="0.66666666666666663" alpha="1" colorSpace="calibratedWhite"/>
30+
<color key="textColor" red="0.66666668653488159" green="0.66666668653488159" blue="0.66666668653488159" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
2831
<nil key="highlightedColor"/>
2932
</label>
3033
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="7yS-V8-d7W">
@@ -36,19 +39,18 @@
3639
<state key="normal" image="infoButtonImage"/>
3740
</button>
3841
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Title" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumFontSize="10" translatesAutoresizingMaskIntoConstraints="NO" id="HxA-Sp-k3F">
39-
<rect key="frame" x="77" y="6" width="362.5" height="20.5"/>
42+
<rect key="frame" x="77.5" y="6" width="362.5" height="20.5"/>
4043
<fontDescription key="fontDescription" type="system" pointSize="17"/>
41-
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
44+
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
4245
<nil key="highlightedColor"/>
4346
</label>
4447
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="😀" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="uUZ-Xh-1Cg" userLabel="SmileyLabel">
4548
<rect key="frame" x="16" y="6" width="46.5" height="46"/>
46-
<fontDescription key="fontDescription" type="system" pointSize="40"/>
47-
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
49+
<fontDescription key="fontDescription" type="system" pointSize="35"/>
50+
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
4851
<nil key="highlightedColor"/>
4952
</label>
5053
</subviews>
51-
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
5254
</view>
5355
<constraints>
5456
<constraint firstItem="HxA-Sp-k3F" firstAttribute="top" secondItem="VA5-fl-7N2" secondAttribute="top" id="0PL-fu-BRq"/>
@@ -78,6 +80,6 @@
7880
</collectionViewCell>
7981
</objects>
8082
<resources>
81-
<image name="infoButtonImage" width="24" height="24"/>
83+
<image name="infoButtonImage" width="48" height="48"/>
8284
</resources>
8385
</document>

ReplaceAnimation/JokeService.swift

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -9,34 +9,38 @@
99
import Foundation
1010

1111
protocol JokeService {
12-
func getJoke(completion : ((Joke?)->Void))
12+
func getJoke(completion : ( @escaping (Joke?)->Void))
1313
}
1414

1515
class JokeWebService : JokeService {
16-
private var dataTask : NSURLSessionTask?
17-
18-
func getJoke(completion: ((Joke?) -> Void)) {
19-
guard dataTask == nil else { return }
2016

21-
let url = NSURL(string: "http://tambal.azurewebsites.net/joke/random")
22-
self.dataTask = NSURLSession.sharedSession().dataTaskWithURL(url!) { (data, response, error) -> Void in
23-
guard let data = data else { completion(nil); return }
17+
private var dataTask : URLSessionTask?
18+
19+
func getJoke(completion: @escaping ((Joke?) -> Void)) {
20+
guard dataTask == nil else { return }
2421

25-
var json: [String:AnyObject]?
26-
do {
27-
json = try NSJSONSerialization.JSONObjectWithData(data, options: NSJSONReadingOptions()) as? [String:AnyObject]
28-
} catch {
29-
completion(nil)
30-
}
22+
let url = URL(string: "https://icanhazdadjoke.com/") //Removed Due to url not working http://tambal.azurewebsites.net/joke/random")
23+
var urlRequest = URLRequest(url: url!)
24+
urlRequest.setValue("application/json", forHTTPHeaderField: "Accept")
3125

32-
completion(Joke(json: json!))
33-
self.dataTask = nil
34-
}
35-
self.dataTask?.resume()
36-
}
37-
38-
func cancelFetch() {
39-
dataTask?.cancel()
40-
dataTask = nil
41-
}
26+
self.dataTask = URLSession.shared.dataTask(with: urlRequest) { (data, response, error) -> Void in
27+
guard let data = data else { completion(nil); return }
28+
29+
var json: [String:AnyObject]?
30+
do {
31+
json = try JSONSerialization.jsonObject(with: data, options: JSONSerialization.ReadingOptions()) as? [String:AnyObject]
32+
} catch {
33+
completion(nil)
34+
}
35+
36+
completion(Joke(json: json!))
37+
self.dataTask = nil
38+
}
39+
self.dataTask?.resume()
40+
}
41+
42+
func cancelFetch() {
43+
dataTask?.cancel()
44+
dataTask = nil
45+
}
4246
}

0 commit comments

Comments
 (0)