example of dictionary in ios
Example 1: swift retrieve value from dictionary
var companies = ["AAPL" : "Apple Inc", "GOOG" : "Google Inc", "AMZN" : "Amazon.com, Inc", "FB" : "Facebook Inc"]
for (key, value) in companies {
print("\(key) -> \(value)")
}
for value in Array(companies.values) {
print("\(value)")
}
print(companies["AAPL"])
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)")