Re: __block __weak - am I doing this right?
Re: __block __weak - am I doing this right?
- Subject: Re: __block __weak - am I doing this right?
- From: Greg Parker <email@hidden>
- Date: Thu, 16 Feb 2012 12:05:47 -0800
On Feb 16, 2012, at 8:22 AM, Matt Neuburg <email@hidden> wrote:
> On Wed, 15 Feb 2012 16:20:50 -0800, Greg Parker <email@hidden> said:
>>
>> Are you using GC or ARC? I think this is safe with GC but not safe with ARC, but I'm not an expert in the NSNotificationCenter machinery.
>
> ARC, but I don't see how it might be unsafe. I sure *hope* it isn't, because that's what the __weak is for. You need that because if your observer doesn't vanish in good order, neither will +self+, because the observer retains +self+, not just while registered with the notification center but for as long as it lives (by way of the block, I presume). *That* is something I *do* understand, having spent many hours watching the retain counts at work.
The question is, who retains the observer? The __block __weak variable does not, because it's weak. NSNotificationCenter does not, as I understand it.
--
Greg Parker email@hidden Runtime Wrangler
_______________________________________________
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