Recently in Xcode 8 beta 6 (8S201h), this has become a problem.
UIApplicationLaunchOptionsShortcutItemKey
Here's the error :
Anyone else having this issue?
var performShortcutDelegate = true
if let shortcutItem = launchOptions[UIApplicationLaunchOptionsKey.shortcutItem] as? UIApplicationShortcutItem {
print("ok")
self.shortcutItem = shortcutItem
performShortcutDelegate = false
}
return performShortcutDelegate
UIAlertController is one of the most… | by Balaji Malliswamy | Swift India | Medium UIAlertController is one of the most basic component of the app development, because using the UIAlertController to get the feedback, confirmation, choose between the options from the user, also we do alerts.
If an optional contains a value in it, it returns value as Optional<Value>, if not it returns nil. Example 1: How to declare an optional in Swift? In the above program, we have initialized a optional type using ? and !. Both ways are valid to create an optional but there is one major difference which we will explore below.
The if-let statement also automatically unwraps the value and places the unwrapped value in temp constant. This technique has major advantage because you don't need to forcely unwrap the value although being certain an optional contains a value. 3. Guard statement You can use guard to handle optionals in Swift.
Because the sorting closure is passed as an argument to a method, Swift can infer the types of its parameters and the type of the value it returns. The sorted (by:) method is being called on an array of strings, so its argument must be a function of type (String, String) -> Bool.
The constant has changed (see the documentation). You also need to unwrap launchOptions
before using any values it contains.
Enclosing function is included for context.
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
if let launchOptions = launchOptions {
if #available(iOS 9.0, *) {
if let shortcutItem = launchOptions[UIApplicationLaunchOptionsKey.shortcutItem] as? UIApplicationShortcutItem {
print("Shortcut: \(shortcutItem)")
}
}
}
return true
}
The launchOptions Dictionary type has changed in the function parameters to [UIApplicationLaunchOptionsKey: AnyObject].
private func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: AnyObject]?) -> Bool {
...
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With