Skip to content

Instantly share code, notes, and snippets.

@terrybu
Created August 1, 2015 18:39
Show Gist options
  • Save terrybu/26397eabffeb8fd1f0ed to your computer and use it in GitHub Desktop.
Save terrybu/26397eabffeb8fd1f0ed to your computer and use it in GitHub Desktop.
swift completion handlers
//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