我有一个 ["2","4","6","8"] 形式的 parse.com 数组。当我检索我的数组时,它是 JSON 格式的。我正在使用 swiftyJSON。我在运行时遇到的错误是动态类型转换失败。这是我的代码。我的 parse.com 数组名称是 Options
if let objects = objects as? [PFObject] {
for object in objects {
println(object.objectId)
let pf = object as PFObject
let name = pf["Question"] as String
// let data1 = pf["Options"] as? NSData
let jsonData: NSData = pf["Options"] as NSData
let json = JSON(data: jsonData)
self.myArray = json.arrayObject as Array<String>
println(name)
self.question.text = name
// println(answers1)
}
}