Tutorial by Examples

[UIView animateWithDuration:1.0 animations:^{ someView.alpha = 0; otherView.alpha = 1; } completion:^(BOOL finished) { [someView removeFromSuperview]; }]; The carat “^” character defines a block. For example, ^{ … } is a block. More specifically, it is a blo...
1- Define Your own custom Block typedef void(^myCustomCompletion)(BOOL); 2- Create custom method which takes your custom completion block as a parameter. -(void) customMethodName:(myCustomCompletion) compblock{ //do stuff // check if completion block exist; if we do not check it will ...
Block will capture variables that appeared in the same lexical scope. Normally these variables are captured as "const" value: int val = 10; void (^blk)(void) = ^{ val = 20; // Error! val is a constant value and cannot be modified! }; In order to modify the variable, you need to ...

Page 1 of 1