Ant*_*y C 6 notifications cloudkit swift3 ios10
我正在尝试userInfo从application:didReceiveRemoteNotification:userInfo:fetchCompletionHandler我的app委托中加载字典.
然后我需要转换userInfo为[AnyHashable:Any],[String:NSObject]所以我可以在CloudKit中使用它CKNotification:fromRemoteNotificationDictionary.
当我做:
let ui = userInfo as! [String : NSObject]
Run Code Online (Sandbox Code Playgroud)
我收到错误:
'[AnyHashable:Any]' is not convertible to '[String:NSObject]'
Run Code Online (Sandbox Code Playgroud)
有没有更好的方法转换userInfo为适当的类型,或者我是在一个完全错误的轨道?
你只需要先将它施放NSDictionary,然后你可以将其投射到[String: NSObject].
试试这样:
CKNotification(fromRemoteNotificationDictionary: userInfo as NSDictionary as! [String: NSObject])
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4823 次 |
| 最近记录: |