我是 Objective-C 的新手,我在使用从 Parse 检索到的数据填充 UItableview 时遇到问题。这是我的查询: - (void)viewDidLoad {
[super viewDidLoad];
PFQuery *query = [PFUser query];
[query orderByAscending:@"username"];
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
if (error) {
NSLog(@"Error: %@ %@", error, [error userInfo]);
} else {
//this is my users array
self.allUsers = objects;
[self.tableView reloadData];
}
}];
我已经记录了这个,可以看到我成功地检索了数据。但是当我尝试如下填充我的 tableView 时。没有数据显示。我究竟做错了什么?
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [self.allUsers count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath];
PFUser *user = [self.allUsers objectAtIndex:indexPath.row];
cell.textLabel.text = user.username;
return cell;
}
在此先感谢您的帮助。