简体   繁体   中英

iOS parse issues when retrieving pointer to PFUser

I have a Follower class where stores all following/follower relations of my app. However, when I was trying to retrieve the pointer of each PFUser, I can't get the attributes of each PFUser. Here is my code

PFQuery *query = [PFQuery queryWithClassName:@"Follower"];
[query whereKey:@"from" equalTo:[PFUser currentUser]];
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error)
{
    if (!error)
    {
        for(PFObject *o in objects)
        {
            PFUser *otherUser = (PFUser *)[o objectForKey:@"to"];
            NSLog(@"%@",otherUser);
            NSLog(@"%@",otherUser.username);

            NSString *nickName = otherUser[@"nickName"];
            cell.friendNameLabel.text = nickName;
            NSLog(@"%@", otherUser[@"nickName"]);
            //cell.friendUsrnameLabel.text = otherUser.username;
            PFFile *imgFile = otherUser[@"profilePhoto"];
            profileView.file = imgFile;
            [profileView loadInBackground];
        }
    }
    else
    {
        NSLog(@"error");
    }

}];

when I tried to print every user, here is what i got from the console:

<PFUser: 0x7fc102ec9f70, objectId: GiOIGiNHjK, localId: (null)> {
}

so it didn't find the attributes of each user. Anyone knows the solution? Thanks. 我在Follower类中使用的联接表

在执行查询之前,尝试添加此行。

[query includeKey:@"to"];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM