/* Checks Is Username Already 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 the failure
println("Error: \(error) \(error!.userInfo!)")
}
completion(isUser: isPresent);
}
}
Kullanıcının ayrıştırma veritabanında olup olmadığını denetleyen bu işlev yöntemini buldum, ancak onu çağırmanın uygun yolu nedir anlamıyorum. checkIsUserExists ("[email protected], comletion ..?)Böyle hızlı bir işlev nasıl çağrılır?
'Shorthand Argument Ad'ları'na göz atın - bunu şöyle diyebilirsiniz: checkIsUserExists (userEmail.text!) {Print ($ 0)} – oren