这是我的Swift 3代码:
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
if let userInfo : Foundation.NSDictionary = launchOptions?[UIApplicationLaunchOptionsKey.remoteNotification] as? Foundation.NSDictionary {
self.setNavigationInfoFromPushNotification(userInfo: userInfo)
navigateFromPushNotification()
}
...
}
导致编译时错误:
对成员'下标'
的模糊引用
请有人帮我这个吗?
答案 0 :(得分:1)
方法签名已更改。请参阅How to handle launch options in Swift 3 when a notification is tapped? Getting syntax problems。
现在是:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey : Any]? = nil) -> Bool {
if let userInfo = launchOptions?[.remoteNotification] as? NSDictionary {
setNavigationInfoFromPushNotification(userInfo: userInfo)
navigateFromPushNotification()
}
...
}