Re: ^Block statement considered harmful for callbacks?
Re: ^Block statement considered harmful for callbacks?
- Subject: Re: ^Block statement considered harmful for callbacks?
- From: Jens Alfke <email@hidden>
- Date: Thu, 25 Apr 2013 10:29:53 -0700
On Apr 25, 2013, at 9:54 AM, Lee Ann Rucker <email@hidden> wrote:
> 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];
> }
It's easier to just use the __weak attribute, if you're using ARC:
__weak Foo *weakRef = self;
^() = {
Foo *wself = weakRef;
// wself may be nil, that's cool because we only want to doStuff if 'self' is still around.
[wself doStuff];
}
Still, I think this is what Oleg called "jumping through hoops". You and I just don't think it's a very significant hoop :)
—Jens
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden