Skip to content

Instantly share code, notes, and snippets.

@mschmulen
Last active August 29, 2015 14:23
Show Gist options
  • Save mschmulen/b55dace6f69cc6529409 to your computer and use it in GitHub Desktop.
Save mschmulen/b55dace6f69cc6529409 to your computer and use it in GitHub Desktop.
import UIKit
public class MyClass {
private let instanceData:String = "yack"
public typealias COMP_CALLBACK_FUNC = (param:String) ->(String)
public func completionCallback( param:String, completionCallback: COMP_CALLBACK_FUNC )
{
completionCallback(param: param)
}
}
let my = MyClass()
my.completionCallback("yack", completionCallback: { (param) -> (String) in
let newString = "\(param)_YACK "
println(newString)
return newString
})
//you can also do it with a trailing closure
my.completionCallback("yack"){ (param) -> (String) in
let newString = "\(param)_YACK "
println(newString)
return newString
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment