cannot convert AnyHashable in swift 3

你离开我真会死。 提交于 2019-12-14 00:44:31

问题


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:


type conversion

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



来源:https://stackoverflow.com/questions/41013323/cannot-convert-anyhashable-in-swift-3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!