在我的项目中,我在Plist文件中有这个词典
dict = ["cola" : 10, "fanta" : 12, "sprite" : 8]
我在这种模式下正常阅读字典
var dictRead = data!["dict"] as? Dictionary<String, AnyObject>
我有这个结果
[cola : 10, fanta : 12, sprite : 8]
但是,如果我想将字典读取为字符串,Int? 我试过
var dictRead = data!["dict"] as? Dictionary<String, Int>
但我有这个错误
lenghtAndRefCount = (unsigned int) 197132388
characters (unsigned [])
Dict ([String:Int]) dict = {}
更新我已在此模式下解决
var dict = data!["dict"] as Dictionary<String, AnyObject>
for dictValue in dict.values {
var someNumb: Int = ("\(dictValue)").toInt()!
}