Skip to content

Commit 4a0db5b

Browse files
committed
Updated syntax to Swift 3
1 parent 070e3e9 commit 4a0db5b

19 files changed

+324
-324
lines changed

Piece.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,34 +24,34 @@ class Piece : NSObject, NSCoding {
2424

2525
required init(coder aDecoder: NSCoder) {
2626

27-
if let title = aDecoder.decodeObjectForKey("title") as? String {
27+
if let title = aDecoder.decodeObject(forKey: "title") as? String {
2828

2929
self.title = title;
3030

3131
}
3232

33-
if let content = aDecoder.decodeObjectForKey("content") as? String {
33+
if let content = aDecoder.decodeObject(forKey: "content") as? String {
3434

3535
self.content = content;
3636

3737
}
3838

3939
}
4040

41-
func encodeWithCoder(aCoder: NSCoder) {
41+
func encode(with aCoder: NSCoder) {
4242

4343
if let title = self.title {
4444

45-
aCoder.encodeObject(title, forKey: "title")
45+
aCoder.encode(title, forKey: "title")
4646

4747
}
4848

4949
if let content = self.content {
5050

51-
aCoder.encodeObject(content, forKey: "content")
51+
aCoder.encode(content, forKey: "content")
5252

5353
}
5454

5555
}
5656

57-
}
57+
}

Prhymer.xcodeproj/project.pbxproj

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,19 +313,22 @@
313313
isa = PBXProject;
314314
attributes = {
315315
LastSwiftUpdateCheck = 0720;
316-
LastUpgradeCheck = 0720;
316+
LastUpgradeCheck = 0800;
317317
ORGANIZATIONNAME = "Shaken Earth";
318318
TargetAttributes = {
319319
E964C20D1C32451500A1AFCD = {
320320
CreatedOnToolsVersion = 7.2;
321321
DevelopmentTeam = TA4U4W7988;
322+
LastSwiftMigration = 0800;
322323
};
323324
E964C2211C32451500A1AFCD = {
324325
CreatedOnToolsVersion = 7.2;
326+
LastSwiftMigration = 0800;
325327
TestTargetID = E964C20D1C32451500A1AFCD;
326328
};
327329
E964C22C1C32451500A1AFCD = {
328330
CreatedOnToolsVersion = 7.2;
331+
LastSwiftMigration = 0800;
329332
TestTargetID = E964C20D1C32451500A1AFCD;
330333
};
331334
};
@@ -466,8 +469,10 @@
466469
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
467470
CLANG_WARN_EMPTY_BODY = YES;
468471
CLANG_WARN_ENUM_CONVERSION = YES;
472+
CLANG_WARN_INFINITE_RECURSION = YES;
469473
CLANG_WARN_INT_CONVERSION = YES;
470474
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
475+
CLANG_WARN_SUSPICIOUS_MOVE = YES;
471476
CLANG_WARN_UNREACHABLE_CODE = YES;
472477
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
473478
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
@@ -511,8 +516,10 @@
511516
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
512517
CLANG_WARN_EMPTY_BODY = YES;
513518
CLANG_WARN_ENUM_CONVERSION = YES;
519+
CLANG_WARN_INFINITE_RECURSION = YES;
514520
CLANG_WARN_INT_CONVERSION = YES;
515521
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
522+
CLANG_WARN_SUSPICIOUS_MOVE = YES;
516523
CLANG_WARN_UNREACHABLE_CODE = YES;
517524
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
518525
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
@@ -531,6 +538,7 @@
531538
IPHONEOS_DEPLOYMENT_TARGET = 9.2;
532539
MTL_ENABLE_DEBUG_INFO = NO;
533540
SDKROOT = iphoneos;
541+
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
534542
TARGETED_DEVICE_FAMILY = "1,2";
535543
VALIDATE_PRODUCT = YES;
536544
};
@@ -547,6 +555,7 @@
547555
PRODUCT_BUNDLE_IDENTIFIER = com.shakenearth.Prhymer;
548556
PRODUCT_NAME = "$(TARGET_NAME)";
549557
PROVISIONING_PROFILE = "";
558+
SWIFT_VERSION = 3.0;
550559
};
551560
name = Debug;
552561
};
@@ -561,6 +570,7 @@
561570
PRODUCT_BUNDLE_IDENTIFIER = com.shakenearth.Prhymer;
562571
PRODUCT_NAME = "$(TARGET_NAME)";
563572
PROVISIONING_PROFILE = "";
573+
SWIFT_VERSION = 3.0;
564574
};
565575
name = Release;
566576
};
@@ -572,6 +582,7 @@
572582
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
573583
PRODUCT_BUNDLE_IDENTIFIER = com.shakenearth.PrhymerTests;
574584
PRODUCT_NAME = "$(TARGET_NAME)";
585+
SWIFT_VERSION = 3.0;
575586
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Prhymer.app/Prhymer";
576587
};
577588
name = Debug;
@@ -584,6 +595,7 @@
584595
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
585596
PRODUCT_BUNDLE_IDENTIFIER = com.shakenearth.PrhymerTests;
586597
PRODUCT_NAME = "$(TARGET_NAME)";
598+
SWIFT_VERSION = 3.0;
587599
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Prhymer.app/Prhymer";
588600
};
589601
name = Release;
@@ -595,6 +607,7 @@
595607
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
596608
PRODUCT_BUNDLE_IDENTIFIER = com.shakenearth.PrhymerUITests;
597609
PRODUCT_NAME = "$(TARGET_NAME)";
610+
SWIFT_VERSION = 3.0;
598611
TEST_TARGET_NAME = Prhymer;
599612
USES_XCTRUNNER = YES;
600613
};
@@ -607,6 +620,7 @@
607620
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
608621
PRODUCT_BUNDLE_IDENTIFIER = com.shakenearth.PrhymerUITests;
609622
PRODUCT_NAME = "$(TARGET_NAME)";
623+
SWIFT_VERSION = 3.0;
610624
TEST_TARGET_NAME = Prhymer;
611625
USES_XCTRUNNER = YES;
612626
};

Prhymer.xcodeproj/xcuserdata/thomas.xcuserdatad/xcschemes/Prhymer.xcscheme

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "0720"
3+
LastUpgradeVersion = "0800"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"

Prhymer/AppDelegate.swift

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,43 +14,43 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
1414

1515
var window: UIWindow?
1616

17-
let fileInBundle = NSBundle.mainBundle().pathForResource("cmudict-0.7b_modified", ofType: "txt");
17+
let fileInBundle = Bundle.main.path(forResource: "cmudict-0.7b_modified", ofType: "txt");
1818
var finder: RhymeFinder?;
1919
var parentViewController: ParentViewController?;
2020
var writingViewController: WritingViewController?;
2121

22-
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
22+
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
2323

2424
finder = RhymeFinder(pathToDict: fileInBundle!);
2525

2626
return true;
2727
}
2828

29-
func getFileURL(fileName: String) -> NSURL {
30-
let manager = NSFileManager.defaultManager()
31-
let dirURL = try! manager.URLForDirectory(.DocumentDirectory, inDomain: .UserDomainMask, appropriateForURL: nil, create: false);
32-
return dirURL.URLByAppendingPathComponent(fileName)
29+
func getFileURL(_ fileName: String) -> URL {
30+
let manager = FileManager.default
31+
let dirURL = try! manager.url(for: .documentDirectory, in: .userDomainMask, appropriateFor: nil, create: false);
32+
return dirURL.appendingPathComponent(fileName)
3333
}
3434

35-
func applicationWillResignActive(application: UIApplication) {
35+
func applicationWillResignActive(_ application: UIApplication) {
3636
// 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.
3737
// 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.
3838
}
3939

40-
func applicationDidEnterBackground(application: UIApplication) {
40+
func applicationDidEnterBackground(_ application: UIApplication) {
4141
// 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.
4242
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
4343
}
4444

45-
func applicationWillEnterForeground(application: UIApplication) {
45+
func applicationWillEnterForeground(_ application: UIApplication) {
4646
// 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.
4747
}
4848

49-
func applicationDidBecomeActive(application: UIApplication) {
49+
func applicationDidBecomeActive(_ application: UIApplication) {
5050
// 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.
5151
}
5252

53-
func applicationWillTerminate(application: UIApplication) {
53+
func applicationWillTerminate(_ application: UIApplication) {
5454
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
5555
}
5656

Prhymer/CompareWordsViewController.swift

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ class CompareWordsViewController: UIViewController {
1717
override func viewDidLoad() {
1818
super.viewDidLoad()
1919

20-
firstTextField!.clearButtonMode = .Always;
21-
secondTextField!.clearButtonMode = .Always;
20+
firstTextField!.clearButtonMode = .always;
21+
secondTextField!.clearButtonMode = .always;
2222

2323
//Looks for single or multiple taps.
2424
let tap: UITapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(CompareWordsViewController.dismissKeyboard))
@@ -27,15 +27,15 @@ class CompareWordsViewController: UIViewController {
2727

2828
@IBAction func buttonTapped(){
2929

30-
let appDelegate = UIApplication.sharedApplication().delegate as! AppDelegate;
30+
let appDelegate = UIApplication.shared.delegate as! AppDelegate;
3131
var findRP = true;
3232

3333
firstTextField?.backgroundColor = UIColor(red:0.44, green:0.76, blue:0.70, alpha:1.0);
3434
firstTextField?.textColor = UIColor(red:0.95, green:1.00, blue:0.74, alpha:1.0);
3535
secondTextField?.backgroundColor = UIColor(red:0.44, green:0.76, blue:0.70, alpha:1.0);
3636
secondTextField?.textColor = UIColor(red:0.95, green:1.00, blue:0.74, alpha:1.0);
3737

38-
let string1 = firstTextField?.text!.stringByTrimmingCharactersInSet(NSCharacterSet.whitespaceAndNewlineCharacterSet()).stringByTrimmingCharactersInSet(NSCharacterSet.punctuationCharacterSet());
38+
let string1 = firstTextField?.text!.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines).trimmingCharacters(in: CharacterSet.punctuationCharacters);
3939

4040
var firstStrings = [String]();
4141
var wordToAdd1 = "";
@@ -55,7 +55,7 @@ class CompareWordsViewController: UIViewController {
5555
}
5656
firstStrings.append(wordToAdd1);
5757

58-
let string2 = secondTextField?.text!.stringByTrimmingCharactersInSet(NSCharacterSet.whitespaceAndNewlineCharacterSet()).stringByTrimmingCharactersInSet(NSCharacterSet.punctuationCharacterSet());
58+
let string2 = secondTextField?.text!.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines).trimmingCharacters(in: CharacterSet.punctuationCharacters);
5959

6060
var secondStrings = [String]();
6161
var wordToAdd2 = "";
@@ -77,22 +77,22 @@ class CompareWordsViewController: UIViewController {
7777

7878
if((string1 == "" || string1 == nil) && (string2 == "" || string2 == nil)){
7979

80-
firstTextField?.backgroundColor = UIColor.redColor();
81-
firstTextField?.textColor = UIColor.whiteColor();
82-
secondTextField?.backgroundColor = UIColor.redColor();
83-
secondTextField?.textColor = UIColor.whiteColor();
80+
firstTextField?.backgroundColor = UIColor.red;
81+
firstTextField?.textColor = UIColor.white;
82+
secondTextField?.backgroundColor = UIColor.red;
83+
secondTextField?.textColor = UIColor.white;
8484
rhymePercentileLabel?.text = "Must enter values";
8585

8686
}else if(string1 == "" || string1 == nil){
8787

88-
firstTextField?.backgroundColor = UIColor.redColor();
89-
firstTextField?.textColor = UIColor.whiteColor();
88+
firstTextField?.backgroundColor = UIColor.red;
89+
firstTextField?.textColor = UIColor.white;
9090
rhymePercentileLabel?.text = "Must enter a value";
9191

9292
}else if(string2 == "" || string2 == nil){
9393

94-
secondTextField?.backgroundColor = UIColor.redColor();
95-
secondTextField?.textColor = UIColor.whiteColor();
94+
secondTextField?.backgroundColor = UIColor.red;
95+
secondTextField?.textColor = UIColor.white;
9696
rhymePercentileLabel?.text = "Must enter a value";
9797

9898
}else{
@@ -101,17 +101,17 @@ class CompareWordsViewController: UIViewController {
101101

102102
for entry in firstStrings{
103103

104-
if(appDelegate.finder!.dictionary[entry.lowercaseString] == nil){
104+
if(appDelegate.finder!.dictionary[entry.lowercased()] == nil){
105105

106-
firstTextField?.backgroundColor = UIColor.redColor();
107-
firstTextField?.textColor = UIColor.whiteColor();
106+
firstTextField?.backgroundColor = UIColor.red;
107+
firstTextField?.textColor = UIColor.white;
108108
rhymePercentileLabel?.text = "Word(s) could not be found";
109109
findRP = false;
110110
break;
111111

112112
}else{
113113

114-
let word = Word(wordName: entry.lowercaseString, phonemeString: appDelegate.finder!.dictionary[entry.lowercaseString]!);
114+
let word = Word(wordName: entry.lowercased(), phonemeString: appDelegate.finder!.dictionary[entry.lowercased()]!);
115115
firstWords.append(word!);
116116

117117
}
@@ -120,17 +120,17 @@ class CompareWordsViewController: UIViewController {
120120

121121
for entry in secondStrings{
122122

123-
if(appDelegate.finder!.dictionary[entry.lowercaseString] == nil){
123+
if(appDelegate.finder!.dictionary[entry.lowercased()] == nil){
124124

125-
secondTextField?.backgroundColor = UIColor.redColor();
126-
secondTextField?.textColor = UIColor.whiteColor();
125+
secondTextField?.backgroundColor = UIColor.red;
126+
secondTextField?.textColor = UIColor.white;
127127
rhymePercentileLabel?.text = "Word(s) could not be found";
128128
findRP = false;
129129
break;
130130

131131
}else{
132132

133-
let word = Word(wordName: entry.lowercaseString, phonemeString: appDelegate.finder!.dictionary[entry.lowercaseString]!);
133+
let word = Word(wordName: entry.lowercased(), phonemeString: appDelegate.finder!.dictionary[entry.lowercased()]!);
134134
secondWords.append(word!);
135135

136136
}

0 commit comments

Comments
 (0)