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: Alex Zavatone <email@hidden>
- Date: Thu, 19 May 2016 12:54:19 -0400
On May 19, 2016, at 12:41 PM, Jens Alfke wrote:
>
>> On May 19, 2016, at 7:51 AM, Alex Zavatone <email@hidden> wrote:
>>
>> Is there a means to have an object know when it's being observed so that it will refuse to nuke itself in this condition?
>
> Nope. Remember, objects don’t “nuke” themselves; they are dealloced when no other objects have references to them. It’s the observer’s responsibility to retain a reference to the target object (observee?) for as long as it’s observing that object. Or at least to have some means of detecting that the target object is going to go away, and removing itself as an observer then.
>
> —Jens
OK, fair enough. Looks like I'll have build a little weak referenced dealy that subclasses dealloc and stops if it detects any observers. Then for any object that I plan on being KVOable, it will have to be be a subclass of NSObject+bubblewrappedKVO, if dealloc is called while observers are still on the object.
Thank you, sir.
Alex Zavatone
_______________________________________________
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