UIApplicationLaunchOptionsShortcutItemKey does not exist in Swift 3?

Recently in Xcode 8 beta 6 (8S201h) this has become a problem.

UIApplicationLaunchOptionsShortcutItemKey 

Here's the error:

enter image description here

Does anyone else have this problem?

 var performShortcutDelegate = true if let shortcutItem = launchOptions[UIApplicationLaunchOptionsKey.shortcutItem] as? UIApplicationShortcutItem { print("ok") self.shortcutItem = shortcutItem performShortcutDelegate = false } return performShortcutDelegate 
+7
swift swift3 xcode8 xcode8-beta6 3dtouch
source share
3 answers

The constant has changed (see documentation ). You also need to deploy launchOptions before using any values ​​that it contains.

The enable feature is enabled 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 } 
+6
source share

The type of the launchOptions dictionary in the function parameters has changed to [UIApplicationLaunchOptionsKey: AnyObject].

 private func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: AnyObject]?) -> Bool { ... } 
+1
source share

Try it. Its work for me using Xcode8, swift3

  //Check for ShortCutItem if #available(iOS 9.0, *) { if let shortcutItem = launchOptions?[UIApplicationLaunchOptionsKey.shortcutItem] as? UIApplicationShortcutItem { } } 
0
source share

All Articles