3
void (^block)();
void (^block1)(int);

The first line declare a block.

The second line declare a block that takes an integer argument.

Now I want a block that accepts another block as an argument:

void (^block2)(<another block>);

How would I do so?

casperOne
  • 73,706
  • 19
  • 184
  • 253
Anonymous White
  • 2,149
  • 3
  • 20
  • 27

1 Answers1

8

Use a typedef, e.g.

typedef void (^BlockTypeToAccept)();
void (^block)(BlockTypeToAccept inner_block);

or combine them directly:

void (^block)( void (^inner_block)() );
kennytm
  • 510,854
  • 105
  • 1,084
  • 1,005
  • Very clear. Would you explain a little about how typedef void (^BlockTypeToAccept)(); work. I mean, usuallly we do typedef double CGFloat;. Now the type being defined is not even on the far right. That's why it's confusing. – Anonymous White Oct 24 '12 at 10:48
  • @HaryantoCiu: The `typedef` is the same as http://stackoverflow.com/questions/4295432/typedef-function-pointer. – kennytm Oct 24 '12 at 11:37