From 2bdd30f9ed3037b775b7a25ad2e2b529957b3dd1 Mon Sep 17 00:00:00 2001 From: Martin Moizard Date: Fri, 1 Sep 2017 09:56:15 +0200 Subject: [PATCH] Migrate to Swift 3 --- Example/AppDelegate.swift | 2 +- Example/ViewController.swift | 14 +++++++------- iOS Example.xcodeproj/project.pbxproj | 6 +++--- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Example/AppDelegate.swift b/Example/AppDelegate.swift index 435f5a2..52ddb56 100644 --- a/Example/AppDelegate.swift +++ b/Example/AppDelegate.swift @@ -28,7 +28,7 @@ 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/ViewController.swift b/Example/ViewController.swift index 7d5703f..2874edc 100644 --- a/Example/ViewController.swift +++ b/Example/ViewController.swift @@ -55,12 +55,12 @@ extension ViewController { // Only set it if we are using Armchair localizations if !Armchair.useMainAppBundleForLocalizations() { - let currentLocalization: NSString = NSBundle.mainBundle().preferredLocalizations[0] as NSString + let currentLocalization: NSString = Bundle.main.preferredLocalizations[0] as NSString // Only set it if we are using a different language than this apps development language - if let developmentLocalization = NSBundle.mainBundle().developmentLocalization { - if currentLocalization != developmentLocalization { + if let developmentLocalization = Bundle.main.developmentLocalization { + if currentLocalization as String != developmentLocalization { languageLabelText = currentLocalization as String - if let displayName = NSLocale(localeIdentifier: currentLocalization as String).displayNameForKey(NSLocaleIdentifier, value:currentLocalization) { + if let displayName = (Locale(identifier: currentLocalization as String) as NSLocale).displayName(forKey: NSLocale.Key.identifier, value:currentLocalization) { languageLabelText = "\(displayName): \(currentLocalization)" } } @@ -143,7 +143,7 @@ extension ViewController { Armchair.opensInStoreKit(false) // This sets a custom tint color (applies only to UIAlertController). - Armchair.tintColor(UIColor.brownColor()) + Armchair.tintColor(tintColor: UIColor.brown) #endif // This sets the Affiliate code you want to use, but is not required. @@ -216,9 +216,9 @@ extension ViewController { } @IBAction func openUrbanApps(_: AnyObject) { - if let url = NSURL(string: "http://urbanapps.com") { + if let url = URL(string: "http://urbanapps.com") { #if os(iOS) - UIApplication.sharedApplication().openURL(url) + UIApplication.shared.openURL(url) #elseif os(OSX) NSWorkspace.sharedWorkspace().openURL(url) #else diff --git a/iOS Example.xcodeproj/project.pbxproj b/iOS Example.xcodeproj/project.pbxproj index c8cf15d..e724d5b 100644 --- a/iOS Example.xcodeproj/project.pbxproj +++ b/iOS Example.xcodeproj/project.pbxproj @@ -194,7 +194,7 @@ F8111E0419A951050040E7D1 = { CreatedOnToolsVersion = 6.0; DevelopmentTeam = 9H3S97RP4K; - LastSwiftMigration = 0800; + LastSwiftMigration = 0830; }; }; }; @@ -422,7 +422,7 @@ PRODUCT_BUNDLE_IDENTIFIER = "com.armchair.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "iOS Example"; PROVISIONING_PROFILE = ""; - SWIFT_VERSION = 2.3; + SWIFT_VERSION = 3.0; }; name = Debug; }; @@ -440,7 +440,7 @@ PRODUCT_BUNDLE_IDENTIFIER = "com.armchair.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "iOS Example"; PROVISIONING_PROFILE = ""; - SWIFT_VERSION = 2.3; + SWIFT_VERSION = 3.0; }; name = Release; };