我有和数组里面的字典值

时间:2018-03-23 09:20:21

标签: ios arrays swift

我有一个字典,该值包含字符串数组,如下所示

arr = ["key":"["a","b","c","d","e","f","g"]"]

我希望新数组像

let array = ["a","b","c","d","e","f","g"]

如何解析

1 个答案:

答案 0 :(得分:1)

您可以通过几种不同的方式访问字典项,最简单的方法是:

let array = arr["key"]

您可能需要有条件地打开它

if let array = arr["key"] as? [String] {
   // rest of code with array
}