Sure, you just invoke it with ()
like any other block, but you need to typecast the value you retrieve from NSArray
. Here's an example (with an added typedef, because otherwise my head hurts):
typedef int (^IntBlock)(void);
IntBlock Block_001 = ^{ return 101; };
IntBlock Block_002 = ^{ return 202; };
NSArray *array = [NSArray arrayWithObjects:Block_001, Block_002, nil];
int x = ((IntBlock)[array objectAtIndex:0]) (); // now x == 101
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…