如何快速获取数组中字典的值

poo*_*rat -4 arrays dictionary swift ios8

我有这样的字典

var dict : [String : Array<String>] = ["Fruits" : ["Mango", "Apple", "Banana"],"Flowers" : ["Rose", "Lotus","Jasmine"],"Vegetables" : ["Tomato", "Potato","Chilli"]]
Run Code Online (Sandbox Code Playgroud)

我想在每个键的数组中获取值如何快速获取?

Vik*_*ica 7

2½年,没有人提到map

好的,拨出一个Dictionary具有可以满足您要求的属性的属性values,您可以这样做:

let values = dict.map { $0.value }
Run Code Online (Sandbox Code Playgroud)