cannot convert AnyHashable in swift 3

2019-06-14 23:15发布

I have following method, which written in swift (before swift 3). below is the method

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

it gives and error of Use of undeclared type AnyHashable. how can I covert this to swift 3. I tried with following.

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

it removes the error, but don't know it act like same way. hope your help with this. thanx in advance.

1条回答
The star\"
2楼-- · 2019-06-14 23:52

type conversion

enter image description here

do like

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

}

for more information you can get from branch in Git

查看更多
登录 后发表回答