3

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 :)

IronManGill
  • 7,222
  • 2
  • 31
  • 52
Yuvaraj M
  • 340
  • 2
  • 13
  • 1
    you 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 Answers2

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
0

Here's a quick example. Hope it helps.

void (^name)(void) = ^ {
//insert code here
};
Vlad
  • 26
  • 3