swift - How do I check if a username is taken with parse? -


i'm little unsure how set query this. can find solutions in php or javascript. please help!

this code snippet used check whether username exits in parse class or not

/* checks username exists         take - username         return - bool (true/false) */      func checkisuserexists(username: string, completion: ((isuser: bool?) -> void)!) {          var ispresent: bool = false;          let query: pfquery = pfquery(classname: "your_class_name")         query.wherekey("your_key", equalto:username)          query.findobjectsinbackgroundwithblock {             (objects: [anyobject]?, error: nserror?) -> void in              if error == nil {                 if (objects!.count > 0) {                     ispresent = true;                 }              } else {                 // log details of failure                 println("error: \(error) \(error!.userinfo!)")             }              completion(isuser: ispresent);         }     } 

Comments

Popular posts from this blog

PHP DOM loadHTML() method unusual warning -

python - How to create jsonb index using GIN on SQLAlchemy? -

c# - TransactionScope not rolling back although no complete() is called -