> My point remains: blocks are dangerous and there is no easy way to
> ensure they are safe. You can't avoid referencing "self" in blocks,
> because it is the very point of almost every callback block. So you
> have to every time to remind yourself to jump through hoops to avoid
> the retain cycles. Nah.


Yes you can. 

MyWeakRef *weakRef = [MyWeakRef weakRefFromObject:self];

^() = {
  Foo *wself = [weakRef originalObject];
  // wself may be nil, that's cool because we only want to doStuff if 'self' is 
still around.
  [wself doStuff];
}
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to