如何使用swift将json的数组转换为数组

时间:2014-10-23 10:19:19

标签: swift

我有这个数组items

var items: [String] = []

prizes[0]__NSCFDictionary

其中一个键值对是

键:to_prizes

值:

Optional(<__NSCFArray 0x787dbfb0>(
94761178,
71959593,
36665808,
54185273,
18953944,
347,
790
)

我怎样才能使swift字符串数组items成为[94761178,....,790]

1 个答案:

答案 0 :(得分:2)

您可以像这样访问此路径:

let prizesDictionary = prizes[0] as NSDictionary
let toPrizesArray = prizesDictionary["to_prizes"] as NSArray
var items: [String] = toPrizesArray as [AnyObject] as [String]