Assume
typedef void (^MyResponseHandler) (NSError *error);
@property (strong, nonatomic) MyResponseHandler ivarResponseHandler;
synthesize ivarResponseHandler = _ivarResponseHandler;
- (void)myMethod:(MyResponseHandler)responseHandler
{
self.ivarResponseHandler = responseHandler;
...
}
Is the assignment to the ivar through the @property correct? I know that in manual memory management you would have needed self.ivarResponseHandler = [responseHandler copy]; to make sure the block was copied from the stack to the heap. But watching Session 322 – Objective-C Advancements in Depth (minute 25) from WWDC 2011, the speaker says that ARC automatically handles the assignment of a block to an ivar. I just wanted to make sure.
bearMountain,
The easiest way to ensure the block is copied is to, in fact, set the
@propertyto use copy. As in:It does everything you need.
Andrew