Created
September 8, 2016 05:47
-
-
Save shortcircuit3/558e82317a3e5171bdee2e33c0128096 to your computer and use it in GitHub Desktop.
Working example of calbacks in swift
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
| //: Playground - noun: a place where people can play | |
| import UIKit | |
| func firstFunction(input: String, completion: (result: String) -> Void) { | |
| print("run first func") | |
| // Need to include parameter labels in function call if | |
| // you also use the labels in the call back definition | |
| completion(result: "we finished!") | |
| } | |
| firstFunction("commands") { (result: String) in | |
| print("got back: \(result)") | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment