简体   繁体   中英

i am trying to parse json data in swift 1.2 here is the code

let jsonResult = NSJSONSerialization.JSONObjectWithData(data!, options: NSJSONReadingOptions.MutableContainers, error: nil) as! NSArray

I am getting error:

Could not cast value of type '__NSDictionaryM' (0x10322f8a8) to 'NSArray' (0x10322f470).## Heading ##

The error says it all, the function is returning an NSDictionary data type and you are trying to type force it to an NSArray, there is no automated conversion between these two types. Check this link to see how to convert the keys into an array, then you can use the keys in the array to access the dictionary values.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM