Skip to content

Instantly share code, notes, and snippets.

typedef int (^AdderBlock)(int a);
AdderBlock MakeAdderBlockThatAdds(int a) {
return [[^(int b) { return a + b; } copy] autorelease];
}
...
AdderBlock addTwo = MakeAdderBlockThatAdds(2);
NSLog(@"%d", addTwo(3)); // logs 5
...