我正在将 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
}
我收到以下错误:
Ambiguous reference to member 'subscript'
如何解决这个问题?
最佳答案
按照@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 中对成员 'subscript' 的引用不明确,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42557652/