我正在将Swift代码从版本2迁移到3。在AppDelegate.swift中,我实现了以下方法:
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject : AnyObject]?) -> Bool {
FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions)
// error below this line
if let notification = launchOptions?[UIApplicationLaunchOptionsKey.remoteNotification] as? [NSObject : AnyObject] {
} else {}
return true
}
我收到以下错误:
成员“下标”含糊不清
我该如何解决这个问题?
最佳答案
遵循@Larme的建议,我通过将方法签名更改为来解决了这个问题:
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey : Any]? = nil) -> Bool {
FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions)
// error below this line
if let notification = launchOptions?[UIApplicationLaunchOptionsKey.remoteNotification] as? [NSObject : AnyObject] {
} else {}
return true
}
关于ios - AppDelegate中对成员“下标”的不明确引用,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/42557652/