Block concatenation
This little function concatenates two blocks in a single one.Useful when you have a single async operation running while multiple callers wish to subscribe for its completion event with a single message like [self doSomethingWithBlock:^{ … }]. The first caller will start the operation, for all the others the block will be concatenated with the first one.
void(^OABlockConcat(void(^block1)(), void(^block2)()))()
{
block1 = [[block1 copy] autorelease];
block2 = [[block2 copy] autorelease];
if (!block1) return block2;
if (!block2) return block1;
void(^block3)() = ^{
block1();
block2();
};
return [[block3 copy] autorelease];
}
