I am a bit familier with the concepts of Blocks but I don't know how to create them in iOS5. Can anyone provide me with a simple example ? Much appreciated :)
Asked
Active
Viewed 253 times
3
-
1you can understand about block concepts then why you can.t use in objective c – Ben10 Aug 30 '12 at 06:04
-
Check [**this**](http://stackoverflow.com/questions/12176961/what-is-the-purpose-of-using-blocks) question asked by SKM. – Nitish Aug 30 '12 at 06:14
-
Here is a link which you are looking for http://stackoverflow.com/questions/12176961/what-is-the-purpose-of-using-blocks – SriKanth Aug 30 '12 at 06:17
2 Answers
4
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

Ben10
- 3,221
- 2
- 34
- 61