Re: cannot form weak reference to ..
Re: cannot form weak reference to ..
- Subject: Re: cannot form weak reference to ..
- From: Roland King <email@hidden>
- Date: Sun, 08 Jan 2012 09:01:55 +0800
On Jan 8, 2012, at 1:35 AM, Matt Neuburg wrote:
> On Wed, 04 Jan 2012 00:26:17 +0800, Roland King <email@hidden> said:
>> I have this line of code, just before a block is enqueued onto a dispatch queue. weakSelf is used in that block.
>>
>> RKHIPCard __weak *weakSelf = self;
>>
>> which is generating the following error
>>
>> objc[15245]: cannot form weak reference to instance (0x89b4100) of class RKHIPCard
>>
>> in certain very occasional circumstances. A bit of logging and it's clear that those circumstances are when the RKHIPCard, self, is in the middle of being deallocated.
>
> Watch the WWDC 2011 video again; you're explicitly told that this is exactly why the weak-strong dance includes a nil test against the strong self inside the block. m.
>
Not the same situation at all. This is all about the runtime disallowing making weak references during dealloc, not testing whether the weak reference is nil. Anyway this thread continued with a fruitful (no pun intended) discussion with an Apple engineer who asked me to rdar it once I'd expanded on the use case.
_______________________________________________
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