背景
我正在尝试加载userInfo
字典来自application:didReceiveRemoteNotification:userInfo:fetchCompletionHandler
在我的应用程序委托中。
然后我需要投射userInfo
from [AnyHashable:Any]
to [String:NSObject]
这样我就可以在 CloudKit 中使用它CKNotification:fromRemoteNotificationDictionary
.
Question
当我做:
let ui = userInfo as! [String : NSObject]
我收到错误:
'[AnyHashable:Any]' is not convertible to '[String:NSObject]'
有没有更好的转换方法userInfo
到适当的类型,还是我走在完全错误的轨道上?
你只需要先将其投射到NSDictionary
然后你可以将它投射到[String: NSObject]
.
尝试这样:
CKNotification(fromRemoteNotificationDictionary: userInfo as NSDictionary as! [String: NSObject])
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)