Server returns json object shown as below: its around 51 objects
[{"location":"Location1","email":"[email protected]","phone":"123456"},{"location":"Location2","email":"[email protected]","phone":"123456789"},
.
.
..
..
..51]
I want to assign this value first tableview to locations and detailview with email and phone number...
code I used is below:
- (void)connectionDidFinishLoading:(NSURLConnection *)connection {
[connection release];
NSString *responseString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
[responseData release];
NSDictionary *dictionary = [responseString JSONValue];
NSArray *response = [dictionary objectForKey:@"location"];
exercises = [[NSArray alloc] initWithArray:response];
[table reloadData];
}
where am I wrong please suggest...
From first glance the response string looks like an array of dictionaries
to access the the data try something like
NSArray* arrayOfDictionaries = [responseString JSONValue];
NSDictionary* firstDictionary = [arrayOfDictionaries objectAtIndex:0];