0

这是我的 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()
    }
    ...
}

它会导致编译时错误,提示:

对成员“下标”的模糊引用

请问有人可以帮我吗?

4

1 回答 1

1

方法签名已更改。请参阅点击通知时如何处理 Swift 3 中的启动选项?遇到语法问题

就是现在:

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey : Any]? = nil) -> Bool { 
    if let userInfo = launchOptions?[.remoteNotification] as? NSDictionary {
        setNavigationInfoFromPushNotification(userInfo: userInfo)
        navigateFromPushNotification()
    }
    ...
}
于 2016-12-26T18:45:20.437 回答