Skip to content

Instantly share code, notes, and snippets.

@dayitv89
Last active December 2, 2016 19:37
Show Gist options
  • Save dayitv89/232ff81d876a451737b60a391e96b81d to your computer and use it in GitHub Desktop.
Save dayitv89/232ff81d876a451737b60a391e96b81d to your computer and use it in GitHub Desktop.
Closure (Blocks in Objective-C) Demo in swift 3.0.1
public class Custom {
var success: ((Bool) -> String)?
public func testBlock() {
print(success!(true))
}
}
let custom = Custom()
custom.success = { success in
print(success)
return "return string from block"
}
print("before block call")
custom.testBlock()
print("after block call")
before block call
true
return string from block
after block call
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment