Re: iOS - the joy of observers and NSInternalInconsistancyException for KVO
Re: iOS - the joy of observers and NSInternalInconsistancyException for KVO
- Subject: Re: iOS - the joy of observers and NSInternalInconsistancyException for KVO
- From: Roland King <email@hidden>
- Date: Fri, 20 May 2016 07:04:51 +0800
> On 20 May 2016, at 04:36, Jens Alfke <email@hidden> wrote:
>
>
>> On May 19, 2016, at 1:24 PM, Alex Zavatone <email@hidden> wrote:
>>
>> In this case, I'm trying to see what is causing this deallocation. In my code, I explicitly remove the observer before I nil the object, so I don't know where this is happening.
>
> If you’re observing an object, you should probably establish a strong reference to it, like by assigning it to an ivar or adding it to an array or something. Otherwise you can’t guarantee that it will stay alive. But since say “nil the object”, which I guess means “nil a variable pointing to the object”, then you should already have a strong reference, so the object shouldn’t get dealloced unless you’ve got a ref-counting error somewhere. (Do you use ARC?)
>
> There is a user default NSBindingDebugLogLevel on Mac OS that you can set to 1, which will generate extra warnings about KVO and bindings. It might do something useful in your case; I can’t remember exactly what it does, but it may produce a warning when an object with observers gets dealloced.
>
> —Jens
Reading the original post he already has the warning about an object being deallocated whilst still having observers attached to it.
This is simply a case of putting a breakpoint on dealloc and working out why the object is being deallocated before you’ve gone through the observation removal code you have.
_______________________________________________
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