Last active
May 5, 2016 18:15
-
-
Save asowers1/e0c3d0da65d01aebbd6d1b1914155550 to your computer and use it in GitHub Desktop.
Use Completion Handlers in Xcode playgrounds
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 | |
import XCPlayground // we import this so we can get the main XCPlayground "page" | |
//create instance of current playground page | |
let page = XCPlayground.XCPlaygroundPage | |
func myCoolFunctionWithCompletion(input: String, completion: (result: String) -> Void) { | |
print("\(input) ... ") | |
completion(result: "we finished!") | |
} | |
myCoolFunctionWithCompletion("start") { | |
(result: String) in | |
print("got back: \(result)") | |
page.currentPage.finishExecution() // finish execution on main page | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment