diff --git a/Armchair.xcodeproj/project.pbxproj b/Armchair.xcodeproj/project.pbxproj index 92f33e6..b674129 100644 --- a/Armchair.xcodeproj/project.pbxproj +++ b/Armchair.xcodeproj/project.pbxproj @@ -591,7 +591,7 @@ INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; IPHONEOS_DEPLOYMENT_TARGET = 7.1; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - MACOSX_DEPLOYMENT_TARGET = 10.9; + MACOSX_DEPLOYMENT_TARGET = 10.10; PRODUCT_MODULE_NAME = "$(PRODUCT_NAME:c99extidentifier)"; PRODUCT_NAME = Armchair; SDKROOT = macosx; @@ -615,7 +615,7 @@ INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; IPHONEOS_DEPLOYMENT_TARGET = 7.1; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - MACOSX_DEPLOYMENT_TARGET = 10.9; + MACOSX_DEPLOYMENT_TARGET = 10.10; PRODUCT_MODULE_NAME = "$(PRODUCT_NAME:c99extidentifier)"; PRODUCT_NAME = Armchair; SDKROOT = macosx; diff --git a/Example/AppDelegate.swift b/Example/AppDelegate.swift index 038569b..435f5a2 100644 --- a/Example/AppDelegate.swift +++ b/Example/AppDelegate.swift @@ -39,7 +39,7 @@ import Cocoa -// @NSApplicationMain // TODO - Needs Xcode 6.1 beta 2 to compile. Figure out a way to support both for the time being + @NSApplicationMain class AppDelegate: NSObject, NSApplicationDelegate { @IBOutlet weak var window: NSWindow! diff --git a/Example/Base.lproj/MainMenu.xib b/Example/Base.lproj/MainMenu.xib index aafc1ca..2fb7e8e 100644 --- a/Example/Base.lproj/MainMenu.xib +++ b/Example/Base.lproj/MainMenu.xib @@ -1,7 +1,7 @@ - + - + @@ -675,7 +675,7 @@ - + diff --git a/Example/ViewController.swift b/Example/ViewController.swift index ec1ae3f..c48555b 100644 --- a/Example/ViewController.swift +++ b/Example/ViewController.swift @@ -213,12 +213,13 @@ extension ViewController { } @IBAction func openUrbanApps(AnyObject) { - let url = NSURL(string: "http://urbanapps.com") + if let url = NSURL(string: "http://urbanapps.com") { #if os(iOS) - UIApplication.sharedApplication().openURL(url) + UIApplication.sharedApplication().openURL(url) #elseif os(OSX) - NSWorkspace.sharedWorkspace().openURL(url) + NSWorkspace.sharedWorkspace().openURL(url) #else #endif + } } } diff --git a/Source/Armchair.swift b/Source/Armchair.swift index 48e8212..62c4f69 100644 --- a/Source/Armchair.swift +++ b/Source/Armchair.swift @@ -621,8 +621,7 @@ public enum ArmchairKey: String, Printable { public var description : String { get { - return self.toRaw() -// return self.rawValue // Changes to rawValue in Xcode 6.1 beta 2 + return self.rawValue } } } @@ -920,7 +919,11 @@ public class Manager : ArmchairManager { var incrementKey = keyForArmchairKeyType(incrementKeyType) // App's version. Not settable as the other ivars because that would be crazy. - var currentVersion: String = NSBundle.mainBundle().infoDictionary[kCFBundleVersionKey] as NSString + let currentVersion = NSBundle.mainBundle().objectForInfoDictionaryKey(kCFBundleVersionKey) as? NSString + if currentVersion == nil { + assertionFailure("Could not read kCFBundleVersionKey from InfoDictionary") + return + } // Get the version number that we've been tracking thus far var currentVersionKey = keyForArmchairKeyType(ArmchairKey.CurrentVersion) @@ -1137,7 +1140,7 @@ public class Manager : ArmchairManager { })) // get the top most controller (= the StoreKit Controller) and dismiss it - if let presentingController = UIApplication.sharedApplication().keyWindow.rootViewController { + if let presentingController = UIApplication.sharedApplication().keyWindow?.rootViewController { if let topController = topMostViewController(presentingController) { topController.presentViewController(alertView, animated: usesAnimation) { println("presentViewController() completed") @@ -1172,7 +1175,7 @@ public class Manager : ArmchairManager { alert.informativeText = reviewMessage alert.addButtonWithTitle(rateButtonTitle) if showsRemindButton() { - alert.addButtonWithTitle(remindButtonTitle) + alert.addButtonWithTitle(remindButtonTitle!) } alert.addButtonWithTitle(cancelButtonTitle) ratingAlert = alert @@ -1225,7 +1228,7 @@ public class Manager : ArmchairManager { modalPanelOpen = false // get the top most controller (= the StoreKit Controller) and dismiss it - if let presentingController = UIApplication.sharedApplication().keyWindow.rootViewController { + if let presentingController = UIApplication.sharedApplication().keyWindow?.rootViewController { if let topController = topMostViewController(presentingController) { topController.dismissViewControllerAnimated(usesAnimation) { if let closure = self.didDismissModalViewClosure { @@ -1325,8 +1328,9 @@ public class Manager : ArmchairManager { //Use the standard openUrl method } else { - let url = NSURL(string: reviewURLString()) - UIApplication.sharedApplication().openURL(url) + if let url = NSURL(string: reviewURLString()) { + UIApplication.sharedApplication().openURL(url) + } } if UIDevice.currentDevice().model.rangeOfString("Simulator") != nil { @@ -1337,10 +1341,11 @@ public class Manager : ArmchairManager { debugLog(" - Or try copy/pasting \(fakeURL) into a browser on your computer.") } #elseif os(OSX) - var url = NSURL(string: reviewURLString()) - var opened = NSWorkspace.sharedWorkspace().openURL(url) - if !opened { - debugLog("Failed to open \(url)") + if let url = NSURL(string: reviewURLString()) { + var opened = NSWorkspace.sharedWorkspace().openURL(url) + if !opened { + debugLog("Failed to open \(url)") + } } #else #endif @@ -1592,23 +1597,25 @@ public class Manager : ArmchairManager { } private func getRootViewController() -> UIViewController? { - var window: UIWindow = UIApplication.sharedApplication().keyWindow - if window.windowLevel != UIWindowLevelNormal { - var windows: NSArray = UIApplication.sharedApplication().windows - for window in windows { - if window.windowLevel == UIWindowLevelNormal { - break + if let window = UIApplication.sharedApplication().keyWindow { + + if window.windowLevel != UIWindowLevelNormal { + var windows: NSArray = UIApplication.sharedApplication().windows + for window in windows { + if window.windowLevel == UIWindowLevelNormal { + break + } } } - } - for subView in window.subviews { - var nextResponder: UIResponder? = subView.nextResponder() - if let responder = nextResponder { - if responder.isKindOfClass(UIViewController) { - return topMostViewController(responder as? UIViewController) + for subView in window.subviews { + var nextResponder: UIResponder? = subView.nextResponder() + if let responder = nextResponder { + if responder.isKindOfClass(UIViewController) { + return topMostViewController(responder as? UIViewController) + } + } - } }