Last active
December 2, 2016 19:37
-
-
Save dayitv89/232ff81d876a451737b60a391e96b81d to your computer and use it in GitHub Desktop.
Closure (Blocks in Objective-C) Demo in swift 3.0.1
This file contains 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
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") |
This file contains 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
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