Search code examples
iosobjective-carraysparse-platformpfquery

PFQuery in which whereKey is pointer


I have 2 classes: Posts class and User class. I have been trying to query Posts class to show only posts from current user's following. I do it like this:

[query whereKey:@"user" containedIn:[PFUser currentUser][@"followings"]];

Column "followings" is array containing objectId of current user's following. My problem seems to lie where the key @"user" in Posts class is pointer to User class and causes this error:

Error: pointer field user needs a pointer value (Code: 102, Version: 1.2.10)

How should I go about this? Thanks in advance.

Edit1: Info added

Here I provide details about the mentioned 2 classes:

  • Posts class

objectId(string)----text(string)----user(pointer)----...

  • User class

objectId(string)----username(string)----followings(array of users'objectId)----...


Solution

  • I have achieved querying only posts from current user's followings by using matchesQuery:

    PFQuery *userQuery = [PFUser query];
    [userQuery whereKey:@"objectId" containedIn:[PFUser currentUser][@"followings"]];
    [query whereKey:@"user" matchesQuery:userQuery];