Re: Need a native guide through "Cannot remove an observer" woods
Re: Need a native guide through "Cannot remove an observer" woods
- Subject: Re: Need a native guide through "Cannot remove an observer" woods
- From: Keary Suska <email@hidden>
- Date: Mon, 28 Apr 2008 15:15:02 -0600
- Thread-topic: Need a native guide through "Cannot remove an observer" woods
on 4/28/08 12:49 PM, email@hidden purportedly said:
> Thanks. I think your hint worked. That is, I'm not sure what you were
> suggesting, but I took a guess, and it seems to have worked. But I
> still don't quite grasp what's going on, so I'm begging for a touch of
> background?
>
> What I did: remove the will/didChange stuff.
>
> What happened: I no longer get the unable-to-remove-observer warning,
> nor the subsequent BAD_ACCESS crash.
>
> Don't willChange and didChange merely notify and observers there may
> be that change is happening? Why would redundant notification be a
> problem (other than perhaps performance, or possibly some obscure
> double-entry kind of response to the change, like adding up each value
> placed into an integer field)?
According to the KVO documentation, KVO notifications are automatically sent
for you when you use KVC-compliant setter accessor methods, such as -setKey
where "Key" is your key name. If you wish to have complete control over when
notifications are sent, you can implement
+automaticallyNotifiesObserversForKey: to return NO. The default is YES for
all keys.
It is possible that either the binding mechanism or NSObjectController
classes use the KVO notifications to manage observation, and so in this case
you would expect to see the warning that you did. This is only a guess,
since I don't believe this is documented anywhere, that I can recall. My
experience with many Apple technologies has been to follow the rules and
don't make any assumptions, except that I find that it is generally safer to
assume that something isn't OK to do if the docs don't mention it, than to
assume it's OK because the docs don't say otherwise.
Best,
Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"
_______________________________________________
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