Swift 3 中没有 UIApplicationLaunchOptionsShortcutItemKey?
UIApplicationLaunchOptionsShortcutItemKey not there in Swift 3?
最近在Xcode 8 beta 6 (8S201h) 中,这已经成为一个问题。
UIApplicationLaunchOptionsShortcutItemKey
这是错误:
还有其他人遇到这个问题吗?
var performShortcutDelegate = true
if let shortcutItem = launchOptions[UIApplicationLaunchOptionsKey.shortcutItem] as? UIApplicationShortcutItem {
print("ok")
self.shortcutItem = shortcutItem
performShortcutDelegate = false
}
return performShortcutDelegate
常量已更改(请参阅 documentation)。在使用它包含的任何值之前,您还需要解包 launchOptions
。
上下文包含封闭函数。
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
}
函数参数中的 launchOptions 字典类型已更改为 [UIApplicationLaunchOptionsKey: AnyObject]。
private func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: AnyObject]?) -> Bool {
...
}
试试这个..它对我有用 Xcode8 , swift3
//Check for ShortCutItem
if #available(iOS 9.0, *) {
if let shortcutItem = launchOptions?[UIApplicationLaunchOptionsKey.shortcutItem] as? UIApplicationShortcutItem {
}
}
最近在Xcode 8 beta 6 (8S201h) 中,这已经成为一个问题。
UIApplicationLaunchOptionsShortcutItemKey
这是错误:
还有其他人遇到这个问题吗?
var performShortcutDelegate = true
if let shortcutItem = launchOptions[UIApplicationLaunchOptionsKey.shortcutItem] as? UIApplicationShortcutItem {
print("ok")
self.shortcutItem = shortcutItem
performShortcutDelegate = false
}
return performShortcutDelegate
常量已更改(请参阅 documentation)。在使用它包含的任何值之前,您还需要解包 launchOptions
。
上下文包含封闭函数。
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
}
函数参数中的 launchOptions 字典类型已更改为 [UIApplicationLaunchOptionsKey: AnyObject]。
private func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: AnyObject]?) -> Bool {
...
}
试试这个..它对我有用 Xcode8 , swift3
//Check for ShortCutItem
if #available(iOS 9.0, *) {
if let shortcutItem = launchOptions?[UIApplicationLaunchOptionsKey.shortcutItem] as? UIApplicationShortcutItem {
}
}