For some reason I want a block to execute during the next iteration of the run loop, so I came up with:
typedef void (^resizer_t)() ;
- (void) applyResizer: (resizer_t) resizer {
resizer() ;
Block_release(resizer) ;
}
- (void) usage {
...
resizer_t resizer = ^() {
// stuff
} ;
[self performSelectorOnMainThread:@selector(applyResizer:)
withObject:(__bridge id) Block_copy((__bridge void *) resizer)
waitUntilDone:NO] ;
}
- Isn't it ironic that I have to cast to void * the argument to Block_copy ?
- Why is the compiler happy with my Block_release when it chokes on Block_copy without the bridge void * cast?
The code seems to work, I didn't detect a leak nor a premature release, but I'm a bit puzzled by the syntax ...