我目前正在尝试将一些对象的JSON表示转换为NSArray。 我使用RestKit通过API获取响应,现在我想将RKResponse转换为对象数组。我该怎么做?
我目前正在尝试将一些对象的JSON表示转换为NSArray。 我使用RestKit通过API获取响应,现在我想将RKResponse转换为对象数组。我该怎么做?
NSData* data = [jsonString dataUsingEncoding:NSUTF8StringEncoding];
NSArray *values = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil]; // if you are expecting the JSON string to be in form of array else use NSDictionary instead
上面的代码适用于iOS 5及以上版本