/* 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);
}
}
Ich fand diese Funktionsmethode, die überprüft, ob der Benutzer in Pars-Datenbank existiert, aber ich bekomme es nicht, was ist der richtige Weg, um es aufzurufen? checkIsUserExists ("[email protected], comletion ..?)Wie man eine solche schnelle Funktion nennt?
Auschecken 'Shorthand Argument Names' - Sie können es so nennen: checkIsUserExists (userEmail.text!) {Print ($ 0)} – oren