有什么方法可以将[NSSTRING:任何]类型的字典映射到另一个[字符串:任何]
我试图将类型的字典[uiimagePickerController.Infokey:任何] to [string:and nyy] type,但似乎是不可能的。结果是零。我发现直接遍历原始dict的迭代,抓住价值并用RawValue插入它。但是,也许我做错了
debugger,表明 [uiimagepickercontroller.infokey:hood下的任何] 是 [nsstring:nocy]
let imagePropsDict: [UIImagePickerController.InfoKey: Any] = getStubbedProps()
var propsDict: [String: Any] = [:]
imagePropsDict.forEach { infoKey, value in
propsDict[infoKey.rawValue] = value
}
和无效的代码:
if let mappedDict = imagePropsDict as? [String: Any] { ... }
I tried to cast dictionary of type [UIImagePickerController.InfoKey: Any] to [String: Any] type, but it seems it's not possible. The result was nil. I've found straightway to iterate throught original dict, grab value and insert it with rawValue. But maybe I'm doing it wrong
debugger showed that [UIImagePickerController.InfoKey: Any] under the hood is [NSString: Any]
let imagePropsDict: [UIImagePickerController.InfoKey: Any] = getStubbedProps()
var propsDict: [String: Any] = [:]
imagePropsDict.forEach { infoKey, value in
propsDict[infoKey.rawValue] = value
}
and the invalid code:
if let mappedDict = imagePropsDict as? [String: Any] { ... }
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论