我是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;
}
在预先感谢您的帮助。
答案 0 :(得分:0)
您需要实施:
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
。