From 5cd0946b5ba2a37b52d25dec9ce591baf9dc3a1f Mon Sep 17 00:00:00 2001 From: Max Bhuiyan Date: Sat, 26 Aug 2017 23:52:44 +1000 Subject: [PATCH] swift 3 conversion in xcode 8.3.3 --- Example.xcodeproj/project.pbxproj | 4 ++++ Example/AppDelegate.swift | 18 +++++++-------- Example/Base.lproj/Main.storyboard | 36 +++++++++++++++++------------- 3 files changed, 33 insertions(+), 25 deletions(-) diff --git a/Example.xcodeproj/project.pbxproj b/Example.xcodeproj/project.pbxproj index d3f585e..04eaf32 100644 --- a/Example.xcodeproj/project.pbxproj +++ b/Example.xcodeproj/project.pbxproj @@ -93,6 +93,7 @@ TargetAttributes = { 834EB8EC1CEB2819008A889B = { CreatedOnToolsVersion = 7.3.1; + LastSwiftMigration = 0830; }; }; }; @@ -249,6 +250,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = io.objcio.Example; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 3.0; }; name = Debug; }; @@ -260,6 +262,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = io.objcio.Example; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 3.0; }; name = Release; }; @@ -282,6 +285,7 @@ 834EB9011CEB2819008A889B /* Release */, ); defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; }; /* End XCConfigurationList section */ }; diff --git a/Example/AppDelegate.swift b/Example/AppDelegate.swift index 64f75d9..bf97777 100644 --- a/Example/AppDelegate.swift +++ b/Example/AppDelegate.swift @@ -22,29 +22,29 @@ class ProfileViewController: UIViewController { class EpisodesViewController: UITableViewController { let episodes = [Episode(title: "Episode One"), Episode(title: "Episode Two"), Episode(title: "Episode Three")] - override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return episodes.count } - override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { - let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) + override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { + let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath) let episode = episodes[indexPath.row] cell.textLabel?.text = episode.title return cell } - override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { - if let vc = segue.destinationViewController as? DetailViewController { + override func prepare(for segue: UIStoryboardSegue, sender: Any?) { + if let vc = segue.destination as? DetailViewController { vc.episode = episodes[tableView.indexPathForSelectedRow!.row] - } else if let nc = segue.destinationViewController as? UINavigationController, - pvc = nc.viewControllers.first as? ProfileViewController { + } else if let nc = segue.destination as? UINavigationController, + let pvc = nc.viewControllers.first as? ProfileViewController { pvc.person = "My Name" } else { fatalError("unknown segue") } } - @IBAction func unwindToHere(segue: UIStoryboardSegue) { + @IBAction func unwindToHere(_ segue: UIStoryboardSegue) { } } @@ -63,7 +63,7 @@ class DetailViewController: UIViewController { class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? - func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { + func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { return true } } diff --git a/Example/Base.lproj/Main.storyboard b/Example/Base.lproj/Main.storyboard index 857ca09..1119337 100644 --- a/Example/Base.lproj/Main.storyboard +++ b/Example/Base.lproj/Main.storyboard @@ -1,9 +1,13 @@ - - + + + + + - + + @@ -29,15 +33,15 @@ - + - + - + - + @@ -71,17 +75,17 @@ - + - + @@ -98,7 +102,7 @@ - + @@ -109,17 +113,17 @@ - + - + @@ -133,7 +137,7 @@ - + @@ -151,7 +155,7 @@ - +