Skip to content

Instantly share code, notes, and snippets.

@mako34
Last active January 4, 2016 15:59
Show Gist options
  • Select an option

  • Save mako34/8644573 to your computer and use it in GitHub Desktop.

Select an option

Save mako34/8644573 to your computer and use it in GitHub Desktop.
iOS blocks,
// 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