I am new to Objective-C, I was following Apple's "Programming with Objective_C", I can't understand this code sample:
void (^(^complexBlock)(void (^)(void)))(void) = ^ (void (^aBlock)(void)) {
//some code
return ^{
//some code
};
};
I was expecting this pattern:
ReturnType ^(blockVariableIdentifier)(ParameterType1, ParameterType2, ...) = ^{
//some code
};
- How was
blockVariableIdentifier
repleaced with(^complexBlock)(void (^)(void))
? - isn't it supposed to have
void
as a return, how come that we havereturn { ... }
?
I find this code confusing, can you explain it ?
code source.
Update:
Given this typedef:
typedef void (^XYZSimpleBlock)(void);
I can simplify the declaration of complexBlock
to:
void (^(^complexBlock)(XYZSimpleBlock))(void);
but I still can't figure out how this is equivalent to
XYZSimpleBlock (^betterBlock)(XYZSimpleBlock);