guys, I am trying to get all the PFUsers whose username is not included in an array (dontShowUsers
. I also want to limit the query with the variable name<
this is one way
println(geoPoint)
user["location"] = geoPoint
let rejectedUsers: [String] = user["rejected"].copy() as [String]
let acceptedUsers: [String] = user["accepted"].copy() as [String]
let ignoredUsers = rejectedUsers + acceptedUsers
var query = PFUser.query()
query.whereKey("location", nearGeoPoint: geoPoint)
query.whereKey("username", notEqualTo: user.username)
query.whereKey("gender", equalTo: user["interestedIn"])
query.whereKey("username", notContainedIn: ignoredUsers)
query.limit = 10
query.findObjectsInBackgroundWithBlock({
(objects: [AnyObject]!, error2: NSError!) -> Void in
if error2 != nil {
println(error2)
} else {
if objects.isEmpty {
println("empty query")
} else {
for object in objects {
self.usernames.append(object.username)
self.userImages.append(object["image"] as NSData)
notice how i had to copy my user["rejected"] array from parse then i used + to create "ignoredUsers"
then i was able to use:
query.whereKey("username", notContainedIn: ignoredUsers)
I would say that you can solve this without using 2 constraints, just before you execute the query, check if name is in the the array, and if it's not, just execute the query.