【发布时间】:2011-01-30 00:34:41
【问题描述】:
我必须调用 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];
}
如您所见,我尝试打印出数组中的条目数,当在 NSURLConnection 的委托中得到 5,在 tableView numberOfRowsInSection 中得到 0。 我想使用从 NSURLConnection 获得的数据来填充表格。我该怎么做?
【问题讨论】:
标签: iphone objective-c cocoa-touch