Created
August 1, 2015 18:39
-
-
Save terrybu/26397eabffeb8fd1f0ed to your computer and use it in GitHub Desktop.
swift completion handlers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Create a Completion Handler | |
func isTextValid(input: String, completion: (result: Bool) -> Void) { | |
if (input == "Vea Software") { | |
completion(result: true) | |
} else { | |
completion(result: false) | |
} | |
}) | |
//Call a Completion Handler | |
isTextValid("Vea Software", { (result) -> Void in | |
if (result == true) { | |
println("working") | |
}else { | |
println("not working") | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment