I encounter some strange problem when I try to query all users from the "User" class It dos not find any Users
var query:PFQuery=PFQuery(className: "User");
query.findObjectsInBackgroundWithBlock {
(objects: [AnyObject]!, error: NSError!) -> Void in
if !(error != nil) {
for(var i=0;i<objects.count;i++){
var object=objects[i] as PFObject;
var name = object.objectForKey("username") as String;
println(name);
}
}
}
I tried replacing
var query:PFQuery=PFQuery(className: "User");
with
var query:PFQuery=PFQuery(className: "AnotherClass");
and everything worked like i should. I think it must be something special about the "User" class
User isn't the appropriate name for the User table. You need to use the following:
var query : PFQuery = PFQuery(className: "_User")
A more appropriate method is:
var query : PFQuery = PFUser.query()
You cannot query users like that. Instead you need:
var findUsers:PFQuery = PFUser.query();
findUsers.whereKey("username", equalTo: searchText.text)
See Parse documentation:
https://parse.com/docs/ios_guide#users-querying/iOS
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With