Parse.com gets PFUser from related PFObject

I save the photo in Parse as a PFObject with the user ID [PFUser currentUser]as one of its keys.

I want to display a photo in the form of a table next to this PFUser. But when I try to get the user - PFUser *user = [self.photo objectForKey:@"user"];- and then try to access the display name of the user, I get the following exception:

Terminating app due to uncaught exception 'NSInternalInconsistencyException', 
reason: 'Key "profilePicture" has no data.  Call fetchIfNeeded before getting 
its value.'

Calling fetchIfNeeded causes the table to crash, and the AnyPic tutorial does exactly what I'm trying to do without using fetchIfNeeded. AnyPic just calls PFUser *user = [self.photo objectForKey:@"user"];and everything works.

Am I missing a step somewhere? Thank!

Here cellForRowAtIndexPath:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath object:(PFObject *)object {
    static NSString *CellIdentifier = @"Cell";

    PhotoCellTest *cell = (PhotoCellTest *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[PhotoCellTest alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier descriptionText:nil userNameText:nil captionText:nil];
    }

    photo = object;
    PFUser *user = [self.photo objectForKey:@"user"];
    PFFile *profilePictureSmall = [user objectForKey:@"profilePicture"];
    cell.profilePicPlaceholder.file = profilePictureSmall;



    return cell;
}

Edit

Here, where I set the keys for PFObject:

PFObject *photo = [PFObject objectWithClassName:@"Photo"];
    [photo setObject:[PFUser currentUser] forKey:@"user"];
    [photo setObject:self.photoFile forKey:@"image"];
    [photo setObject:[nameField text] forKey:@"itemCaption"];

And here, where I install the keys for PFUser:

PFFile *profilePic = [PFFile fileWithData:data];
    [[PFUser currentUser] setObject:profilePic forKey:@"profilePicture"];
    [[PFUser currentUser] saveInBackground];

NSLog user, <PFUser:nOpK5splEX:(null)> { }, NSLog [PFUser currentUser], <PFUser:nOpK5splEX:(null)> { displayName = "XXX"; facebookId = XXX; profilePicture = "<PFFile: XXX>"; username = XXX;}... , , PFUser .

- , - ?

+5
2

- includeKey PFQuery.

+8

PFUser *user = [self.photo objectForKey:@"user"];

[user fetchIfNeeded];

+3

All Articles