我必須做出NSURLConnection的通話,並具有以下委託:NSURLConnection的代表和填充表視圖
- (void)connectionDidFinishLoading:(NSURLConnection *)connection {
[connection release];
NSString *responseString = [[NSString alloc] initWithData:responseData
encoding:NSUTF8StringEncoding];
[responseData release];
results = [NSArray array];
results = [responseString JSONValue];
NSLog(@"Number of rows: %d", [results count]);
}
//table view number of rows
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
// Return the number of rows in the section.
//return [_userInfo.friendsInfo count];
NSLog(@"Number of rows: %d", [results count]);
return [results count];
}
正如你可以看到我試圖打印出數組中的條目數,我得到了5當NSURLConnection的委託內部和0時,tableView numberOfRowsInSection。 我想使用我從NSURLConnection獲得的數據填充表格。我怎樣才能做到這一點?