【发布时间】:2014-11-02 16:01:29
【问题描述】:
我有一本 Swift 字典。我想得到我的钥匙的价值。关键方法的对象对我不起作用。如何获取字典键的值?
这是我的字典:
var companies = ["AAPL" : "Apple Inc", "GOOG" : "Google Inc", "AMZN" : "Amazon.com, Inc", "FB" : "Facebook Inc"]
for name in companies.keys {
print(companies.objectForKey("AAPL"))
}
【问题讨论】:
-
"您还可以使用下标语法从字典中检索特定键的值……
if let airportName = airports["DUB"] { … }"
标签: dictionary swift key-value