Example blocks in ios5

I'm a bit familier with block concepts, but I don't know how to create them in iOS5. Can someone provide me with a simple example? Very much appreciated :)

+5
source share
2 answers

Use this simple example in blocks.

int multiplier = 7;
int (^myBlock)(int) = ^(int num) {
return num * multiplier;
};



NSLog(@"Sum = %d",myBlock(20));
Then you will get as 140
+4
source

Here is a brief example. Hope this helps.

void (^name)(void) = ^ {
//insert code here
};
0
source

All Articles