PFQuery includeKey 似乎不起作用:关键数据不可用

PFQuery includeKey doesn't seem to be working: Key data unavailible

我正在构建一个社交应用程序,目前正在构建一个 PFQueryTable 视图控制器,我想为在上一个屏幕中选择的用户显示关注者列表。

在 queryForTable 下,我设置了以下查询:

-(void) queryForTable {

PFQuery *query = [PFQuery queryWithClassName:self.parseClassName];
    [query whereKey:@"type" equalTo:@"follow"];
    [query whereKey:@"fromUser" equalTo:self.user];
    [query whereKey:@"toUser" notEqualTo:self.user];
    [query whereKeyExists:@"toUser"];
    [query includeKey:@"toUser"];
    [query orderByDescending:@"createdAt"];

    [query setCachePolicy:kPFCachePolicyNetworkOnly];

    return query;

}

当我为 cellForRowAtIndexPath 下的对象执行 NSLog 时:

- (FollowViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath object:(PFObject *)object {
    static NSString *FollowCellIdentifier = @"FriendCell";

    FollowViewCell *cell = [tableView dequeueReusableCellWithIdentifier:FollowCellIdentifier];
    if (cell == nil) {
        cell = [[FollowViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:FollowCellIdentifier];
    }

    NSLog(@"OBJECT IS %@",object);


    cell.userLabel.text = [[object objectForKey:@"toUser"] objectForKey:@"username"];



        return cell;
}

结果是

OBJECT IS { ACL = ""; fromUser = ""; toUser = ""; type = follow; }

如果我尝试创建:

cell.userLabel.text = [[object objectForKey:@"toUser"] objectForKey:@"username"];

控制台给我一个错误:

'Key "username" has no data. Call fetchIfNeeded before getting its value.'

如果我用中断来逐步执行该过程,userLabel.text 会很好地填充。但是如果我 运行 它没有中断,我总是会得到错误。我在这里遗漏了什么吗?

任何帮助都会很棒,因为我在过去 4 天里一直在努力解决这个问题。

尝试:

PFUser *user = (PFUser *)[object objectForKey:@"toUser"];
[user fetchIfNeededInBackgroundWithBlock:^(PFObject *object, NSError *error) {
  cell.userLabel.text = [object objectForKey:@"username"];
}];