dictionary swift code example
Example 1: how to get key for dictionary in swift
var array_has_dictionary = [
[
"name" : "xxxx",
"age" : "xxxx",
"last_name":"xxx"
],
[
"name" : "yyy",
"age" : "yyy",
"last_name":"yyy"
],
]
cell.textLabel?.text = Array(array_has_dictionary[1])[1].key
Example 2: create dictionary swift
var someDict:[String:Int] = ["One":1, "Two":2, "Three":3]
var someVar = someDict["One"]
print("The value of key = One is \(someVar)")
Example 3: dictionary in swift
var someDict = [KeyType: ValueType]()