FROM : Joakim Danielson
DATE : Sun Jul 02 11:25:26 2006
Why don't you use setKeys:triggerChangeNotificationsForDependentKey: ?
http://developer.apple.com/documentation/Cocoa/Conceptual/
KeyValueObserving/index.html#//apple_ref/doc/uid/10000177i
Joakim
1 jul 2006 kl. 17.43 skrev Daniel Jalkut:
>
> I'm using KVO to observe a keypath relative to "self." For example,
> I'm observing "myTree.apples" from an object with a keyed object
> "myTree."
>
> This is very convenient because it means I don't have to carefully
> manage the addObserver/removeObserver status as "myTree" changes.
> But I've noticed that KVO, in an attempt to protect me from "bad
> stuff" actually limits my ability to use this technique.
>
> In the object's "dealloc" method, it removes observation of itself.
> This should have the effect of cleaning everything up, right? But
> apparently KVO interferes much earlier - detecting my impending
> dealloc and warning me about the fact that there is still an observer:
>
>> An instance 0x38f6a0 of class CueSpecifier is being deallocated
>> while key value observers are still registered with it. Break on
>> _NSKVODeallocateLog to start debugging.
>
> What's worse, is it apparently then removes the observer for me, so
> that when my responsible "self cleanup" occurs moments later, I see
> this in the console:
>
>> Exception ignored while releasing an object in an autorelease
>> pool: [<CueSpecifier 0x38f6a0> removeObserver:<CueSpecifier
>> 0x38f6a0> forKeyPath:@"cueHandler.parameterMenuItems"] was sent to
>> an object that has no observers.
>
> I guess this is tricky because KVO's watch-dogging is happening at
> the sneaky isa-swizzling level.
>
> What are my options? Does anybody have a clean solution for
> observing self keypaths from self? I could figure out some way to
> manually remove observation before being dealloc'd, but at that
> point the convenience factor pretty much disappears.
>
> Daniel
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Cocoa-dev mailing list (<email_removed>)
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/<email_removed>
>
> This email sent to <email_removed>
DATE : Sun Jul 02 11:25:26 2006
Why don't you use setKeys:triggerChangeNotificationsForDependentKey: ?
http://developer.apple.com/documentation/Cocoa/Conceptual/
KeyValueObserving/index.html#//apple_ref/doc/uid/10000177i
Joakim
1 jul 2006 kl. 17.43 skrev Daniel Jalkut:
>
> I'm using KVO to observe a keypath relative to "self." For example,
> I'm observing "myTree.apples" from an object with a keyed object
> "myTree."
>
> This is very convenient because it means I don't have to carefully
> manage the addObserver/removeObserver status as "myTree" changes.
> But I've noticed that KVO, in an attempt to protect me from "bad
> stuff" actually limits my ability to use this technique.
>
> In the object's "dealloc" method, it removes observation of itself.
> This should have the effect of cleaning everything up, right? But
> apparently KVO interferes much earlier - detecting my impending
> dealloc and warning me about the fact that there is still an observer:
>
>> An instance 0x38f6a0 of class CueSpecifier is being deallocated
>> while key value observers are still registered with it. Break on
>> _NSKVODeallocateLog to start debugging.
>
> What's worse, is it apparently then removes the observer for me, so
> that when my responsible "self cleanup" occurs moments later, I see
> this in the console:
>
>> Exception ignored while releasing an object in an autorelease
>> pool: [<CueSpecifier 0x38f6a0> removeObserver:<CueSpecifier
>> 0x38f6a0> forKeyPath:@"cueHandler.parameterMenuItems"] was sent to
>> an object that has no observers.
>
> I guess this is tricky because KVO's watch-dogging is happening at
> the sneaky isa-swizzling level.
>
> What are my options? Does anybody have a clean solution for
> observing self keypaths from self? I could figure out some way to
> manually remove observation before being dealloc'd, but at that
> point the convenience factor pretty much disappears.
>
> Daniel
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Cocoa-dev mailing list (<email_removed>)
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/<email_removed>
>
> This email sent to <email_removed>
| Related mails | Author | Date |
|---|---|---|
| Daniel Jalkut | Jul 1, 17:43 | |
| Joakim Danielson | Jul 2, 11:25 | |
| Daniel Jalkut | Jul 3, 02:06 |






Cocoa mail archive

