解析Json
1 #pragma mark- 解析JSON数据 2 - (NSArray *)parseJSONData:(NSData *)data error:(NSString **)error { 3 NSMutableArray *videos = nil; 4 5 NSDictionary *dict = [data JSONValue]; 6 7 NSString *myerror = [dict objectForKey:kError]; 8 // 有错误信息 9 if (myerror) { 10 *error = myerror; 11 } else { 12 NSArray *array = [dict objectForKey:kVideos]; 13 videos = [NSMutableArray array]; 14 for (NSDictionary *obj in array) { 15 Video *v = [Video videoWithDict:obj]; 16 [videos addObject:v]; 17 } 18 } 19 20 return videos; 21 }