Analysis - check if user exists
I have a problem with Parse.com.
I want to check if the user already exists. I do it with the following code:
PFQuery *query = [PFUser query];
if ([query whereKey:@"username" equalTo:textField.text]) {
NSLog(@"User exist");
}
else{
NSLog(@"User don`t exist");
}
But every time I check, it says "User exists". But this is impossible.
How can I fix this?
+3
source to share
1 answer
You should have something more:
PFQuery *query = [PFUser query];
[query whereKey:@"username" equalTo:textField.text];
[query getFirstObjectInBackgroundWithBlock:^(PFObject *object, NSError *error) {
if (object != nil) {
NSLog(@"User exist");
}
else
{
NSLog(@"User don`t exist");
}
}];
+11
source to share