0

I have a Parse class "Posts". "Posts" has a column, "user" which stores the user that made the post. It is of type Pointer<_User>.

I want to be able to retrieve the user, and then get an image stored in the User class.

So far I have:

PFQuery *postQuery = [PFQuery queryWithClassName:@"Post"];
[postQuery includeKey:@"user"];
PFObject *result = [postQuery getFirstObject];

if (result) {
    NSLog(@"successful query"); //Successful!
} else {
    NSLog(@"unsuccessful query");
}

PFUser *user = result[@"user"];
if (user) {
    NSLog(@"successful found user");
} else {
    NSLog(@"unsuccessful found user"); //Not successful
}

I successfully get "result", but I no "user". What am I missing?

4

1 回答 1

1

In this case, the User object pointed to had been deleted. If a pointer column is included and it resolves to a non-existing object, it won't fail, but the object won't be fetched/included either. You can probably detect this scenario after query w/ includeKey by checking for the createdAt field.

于 2014-07-11T20:44:22.827 回答