从NSDictionary转换为[String:Any?] [英] Convert from NSDictionary to [String:Any?]
本文介绍了从NSDictionary转换为[String:Any?]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用xmartlabs/Eureka构建具有动态表单的应用程序.
I am using xmartlabs/Eureka to build an app with a dynamic form.
要填写表格,我必须使用setValues(values: [String: Any?])
.
In order to fill the form I have to use setValues(values: [String: Any?])
.
但是我在NSDictionary
变量中有表单值,因此无法将其强制转换为[String:Any?]
.
But I have the form values in an NSDictionary
variable and I cannot cast it to [String:Any?]
.
是否可以将NSDictionary
转换为[String:Any?]
?
推荐答案
希望这会有所帮助:
let dict = NSDictionary()
var anyDict = [String: Any?]()
for (value, key) in dict {
anyDict[key as! String] = value
}
这篇关于从NSDictionary转换为[String:Any?]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文