AppDelegate中对成员'下标'的模糊引用

时间:2017-03-02 14:09:24

标签: ios swift swift3 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
}

我收到以下错误:

  

对成员'下标'的模糊引用

我该如何解决这个问题?

1 个答案:

答案 0 :(得分:0)

遵循@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
}