前端之家收集整理的这篇文章主要介绍了
Swift 字典,
前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
var dictionary = ["name":"LJF","age":"100"]
println(dictionary)
dictionary["height"] = "175"
println(dictionary)
dictionary.removeValueForKey("height")
println(dictionary)
dictionary["name"] = "TXM"
println(dictionary)
let returnValue = dictionary.updateValue("99",forKey: "age")
let returnValue2 = dictionary.updateValue("99",forKey: "age1")
println("returnValue = \(returnValue)","dictionary = \(dictionary)")
println("returnValue = \(returnValue2)","dictionary = \(dictionary)")
for (key,value) in dictionary{
println("key = \(key)","value = \(value)")
}
var initDictionary:[String:String] = [String :String]()
var initDictionary2:Dictionary<String,String> = Dictionary()