Last active
January 4, 2016 15:59
-
-
Save mako34/8644573 to your computer and use it in GitHub Desktop.
iOS blocks,
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
| // since iOS 4, extension C lang | |
| //AKA, lambdas, anonimous functions, clousures | |
| //function that can be stored as a variable (referred to as a "first-class function") | |
| //clousure scope incorporates parent scope "close" | |
| //encapsulate chunks of code and pass them around like any other object | |
| //As well as containing executable code, a block also has the ability to capture state from its enclosing scope. | |
| /* | |
| Compared to functions | |
| Func structure: | |
| return type -- func name -- arguments-- body | |
| int myFunc (int a) { //code } | |
| call: | |
| int myVar = myFunc | |
| STRING VARIABLE STRING LITERAL | |
| NSString *message = @"hola mundo"; | |
| Block structure: | |
| BLOCK VARIABLE BLOCK LITERAL | |
| int (^myFirstBlock) (int) = ^(int a) { //code } | |
| CAN use just the block literal directly | |
| ^(int a){ // my poetry } | |
| */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment