3 ms·
Using blocks is the one bit of Objective-C that still reminds me of the old MRR style. Just like with retain/release/autorelease, it's one thing understanding t
by chrisdevereux 13y ago
Using blocks is the one bit of Objective-C that still reminds me of the old MRR style. Just like with retain/release/autorelease, it's one thing understanding the pattern, it's another ensuring that your entire program conforms to it. Anywhere that you capture nontrivial objects is a possible failure point.
ReactiveCocoa has some nice patterns for avoiding block callbacks altogether. Eg:
[myTarget rac_liftSelector:@selector(receiveCallback:) withSignals:mySignal, nil];
will capture a weak reference to the target, invoke the callback whenever 1 or more events fire and automatically unsubscribe when the target deallocates.