【发布时间】:2014-09-30 17:16:48
【问题描述】:
生日,
我正在尝试使用 for 循环来访问 Swift 中字典数组中相同键的值。
例如,
let dictionaryOne = [
"name": "Peter",
"age": "42",
"location": "Milwaukee"]
let dictionaryTwo = [
"name": "Paul",
"age": "89",
"location": "Denver"]
let arrayOfDictionaries = [dictionaryOne, dictionaryTwo]
我正在尝试使用 for 循环创建一个函数,该循环将输出一个包含位置值的数组,即 ["Milwaukee", "Denver"]
我查看了其他回复,但我只能找到如何直接从字典本身访问“位置”的值,如果有许多不同的字典而不是只有两个字典,这将很麻烦。
非常感谢您提供的任何帮助!
【问题讨论】:
标签: arrays dictionary swift