繁体   English   中英

AppDelegate中对成员“下标”的不明确引用

[英]Ambiguous reference to member 'subscript' in AppDelegate

我正在将我的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
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM