无法在swift 3中转换AnyHashable

时间:2016-12-07 09:08:58

标签: ios swift3 branch.io

我有以下方法,用swift编写(在swift 3之前)。以下是方法

func application(application: UIApplication, didReceiveRemoteNotification launchOptions: [AnyHashable: Any]) -> Void {
    Branch.getInstance().handlePushNotification(launchOptions)
}

它给出了Use of undeclared type AnyHashable的错误。我怎样才能把它转变为迅速3.我尝试了以下。

 func application(application: UIApplication, didReceiveRemoteNotification launchOptions: [NSObject : AnyObject]) -> Void {
        Branch.getInstance().handlePushNotification(launchOptions)
    }

它删除了错误,但不知道它的行为方式相同。希望你对此有所帮助。提前完成。

1 个答案:

答案 0 :(得分:8)

类型转换

enter image description here

喜欢

func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any]) {
print("received a notification")
   Branch.getInstance().handlePushNotification(launchOptions)

}

您可以从branch in Git

获取更多信息