0
votes

I'm trying to find users nearby the current logged user but somehow the result object isnt returning any user.

var currentUserGeoPoint = PFUser.currentUser()!["currentLocation"] as! PFGeoPoint

var query = PFQuery(className:"User")
    query.whereKey("currentLocation", nearGeoPoint: currentUserGeoPoint, withinKilometers: 100)
    query.findObjectsInBackgroundWithBlock {
        (objects, error) -> Void in
        if (error == nil) {
            println(objects)
        }else {
            println(error?.userInfo)
        }
}

Console return: Optional([])

This is my User Table: enter image description here

As you can see my User class is set as public. (I know it is not best practice) enter image description here

1
can you post a picture of your parse - Lamour

1 Answers

0
votes

Class name should be _User.

var query = PFQuery(className:"_User")
    query.whereKey("currentLocation", nearGeoPoint: currentUserGeoPoint, withinKilometers: 100)
    query.findObjectsInBackgroundWithBlock {
        (objects, error) -> Void in
        if (error == nil) {
            println(objects)
        }else {
            println(error?.userInfo)
        }
}