2

I have a class of users in Parse named "User".

I set a PFRelation of user with other users like this :

  let relation : PFRelation = currentUser.relationForKey("KfriendsRelation")

Lets say i have user 1, i can retrieve all users that this particular user follow with this :

    if let friendsRelation: AnyObject! = userPassed.objectForKey("KfriendsRelation")  {

        println(friendsRelation)

        if friendsRelation != nil {

     let findUser : PFQuery = friendsRelation.query()
            findUser.whereKey("objectId", notEqualTo: PFUser.currentUser().objectId)


    findUser.findObjectsInBackgroundWithBlock....

What should i do if i want to retrieve all users that follow user 1 ?

I made this but it doesn't work :

      let findUser : PFQuery =  PFUser.query()
             findUser.whereKey("kfriendsRelation", equalTo: user 1)



                findUser.findObjectsInBackgroundWithBlock { (objects:[AnyObject]!, error:NSError!) -> Void in
                    if !(error != nil) {
                        // The find succeeded.
                        println("succesfull load Users in FollowingTableView")
                        println(objects.count)
                        // Do something with the found objects
                        for object  in objects  {
                            self.followingUserList.addObject(object)
                            println(object)
                        }
                        self.tableView.reloadData()
                    } else {
                        // Log details of the failure
                        println("error loadind user ")
                        println("error")
                    }

                }     }

It print me "succesfull load Users in FollowingTableView" but println(object.count) print me "0". I am sure there are objects so i m confused...

jmcastel
  • 1,365
  • 7
  • 17
  • 34

1 Answers1

1

The built-in User class does not have "User" as its classname. If you're querying the built-in User class, you should use the PFQuery object returned by PFUser's query method instead of querying over a "User" class.

Héctor Ramos
  • 9,239
  • 6
  • 36
  • 39
  • I tested it as you can see in my edited code but have the same result. Sorry for the noob question... – jmcastel Oct 30 '14 at 21:14