2012-01-17 62 views
0

服務器返回顯示JSON對象如下:其約51物體JSON對象的UITableView

[{"location":"Location1","email":"[email protected]","phone":"123456"},{"location":"Location2","email":"[email protected]","phone":"123456789"}, 
. 
. 
.. 
.. 
..51] 

我要分配給此值第一的tableview到位置和使用的DetailView電子郵件和電話號碼...

代碼我用低於:

- (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]; 
} 

我在哪裏錯了,請建議...

回答

2

從乍一看響應字符串看起來像字典

數組

訪問數據嘗試像

NSArray* arrayOfDictionaries = [responseString JSONValue]; 
NSDictionary* firstDictionary = [arrayOfDictionaries objectAtIndex:0];