swift how to get the value for a key in a dictionary code example
Example: 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)")
}
//Or if you only want the values:
for value in Array(companies.values) {
print("\(value)")
}
// One value with direct access on the dictionary:
print(companies["AAPL"])