var hash = Dictionary<Int,Any>()
hash[11] = ["1111","22222"]
println(hash)
for (key,value) in hash{
print("key:\(key) , hi")
print(value)
for i in [value] {
print(" ggg \(i)")
}
}
我只是在swift中测试dict并且有这样的问题。在哈希中存储数组[&#34; 1111&#34;,&#34; 2222&#34;]之后,我得到了&#34; [&#34; 1111&#34;,&## 34; 2222&#34;]&#34; 。有人可以帮忙吗?
答案 0 :(得分:0)
我想,你想要的是:
for (key,value) in hash {
if let vals = value as? Array<String> {
for str in vals {
print("string: \(str)")
}
}
}