Skip to content

Instantly share code, notes, and snippets.

@shortcircuit3
Created September 8, 2016 05:47
Show Gist options
  • Select an option

  • Save shortcircuit3/558e82317a3e5171bdee2e33c0128096 to your computer and use it in GitHub Desktop.

Select an option

Save shortcircuit3/558e82317a3e5171bdee2e33c0128096 to your computer and use it in GitHub Desktop.
Working example of calbacks in swift
//: 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