self.myArray = @[ [^{ NSLog(@"a"); } copy],
[^{ NSLog(@"b"); } copy]];
... Later ....
[self.myArray enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
// This syntax is wrong, but I hope you get my intention
void (^) (void) block = obj;
block();
}];
How do you cast out the block when enumerating over it? (Bonus if you can do it without a typedef)
[self.myArray enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
void (^block)() = obj;
block();
}];
Or directly in the argument list:
[self.myArray enumerateObjectsUsingBlock:^(void (^block)(), NSUInteger idx, BOOL *stop) {
block();
}];
This should work:
void (^block )(void) = obj;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With