0
我一直在寻找一段时间没有成功,需要一个答案。字典值包含字典和值包含数组
我在找的数据结构是一个有键和值的字典。该值是字典并将数组作为值。
例如:
"San Francisco" -> "Stores", -> "Apple Store", "...", ".."
"Companies" -> "...", ".."
"New York" -> "Fast Food" -> "Mc", "BK", "KFC"
我怎样才能做到这一点?
我试着用
var nest = [String: [String: [String]]]()
nest["New York"]["Fast Food"] = ["MC", "BK"]
这似乎不正常。
不过,我能做到这一点
var fastfood = [String: [String]]()
var names = [String]()
fastFood["Fast Food"] = names
nest["New York"] = fastFood
这个原因问题的路线。我需要每次创建一个对象。我从数据库中获取数据,并需要将传入的数据直接附加到嵌套。
那好。我也这么认为,但是在抓取过程中尝试使用它会变得有些复杂。由于提取是异步的,“分类法”总是空的。 – Kray
请看看我的另一个问题http://stackoverflow.com/questions/43521362/download-multiple-files-containing-data-points-one-file-per-time?noredirect=1#comment74100518_43521362 – Kray