I have created an API and the results are given out in json in the following format:
{"response":"ok","data":[{"file_name":"sample file name one","server_url":"someurl","file_thumb":"images\/7ibysd4f8wiy_t.jpg"},{"file_name":"sample file name two","server_url":"someurl","file_thumb":"images\/jm3t6aat8uhq_t.jpg"}]}
till now I was using the following function:
- (NSArray*) jsonToArray:(NSString *)responseData{
NSData* data = [responseData 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
return values;
}
and then I would get the array like:
data_array = [self jsonToArray:data_js];
[data_array valueForKey:@"data"]
but how I be able to loop through the data
array? is that possible with the current method?