4. Block
The closure that Apple adds to C
Is an object (NSBlock)
The compiler translate block literals into struct
and functions. So we don’t see the alloc call
5. Block
It is said to be the only object that can be
allocated on the stack, by default.
It is moved to heap when copied.
8. Syntax
The syntax of Objective C block http://arigrant.
com/blog/2014/1/18/the-syntax-of-objective-c-blocks
From C declarators to Objective C block syntax
http://nilsou.com/blog/2013/08/21/objective-c-blocks-syntax/
Cheatsheet
http://fuckingblocksyntax.com/
10. Syntax
() > [] > *, ^
Start from the variable name to right
Then to the left
Operator precedence http://unixwiz.net/techtips/reading-cdecl.html
CDECL http://cdecl.org/
35. __block
What does the block keyword mean
http://stackoverflow.com/questions/7080927/what-does-the-block-keyword-
mean
36. __block
Access to __block variable
http://clang.llvm.org/docs/Block-ABI-Apple.html#layout-of-block-marked-
variables
By default, variables used withtin the block are
copied
Rewrite access,
42. weakSelf vs strongSelf
Block is allocated on the stack. It has no effect
on the storage of lifetime of anything it
accesses.
When they are copied, they take their captured
scope with them, retaining any objects they
refer
50. Notification handler block
[[NSNotificationCenter defaultCenter]
addObserverForNotificationName:@"NotificationName"
object:nil
queue:[NSOperationQueue mainQueue]
block:^(NSNotification *notification) {
//reload the table to show the new whiz bangs
NSAssert(notification, @"Notification must not be nil");
[self.tableView reloadData];
}];