Console: *** -observeValueForKeyPath:... only defined for abstract class
Console: *** -observeValueForKeyPath:... only defined for abstract class
- Subject: Console: *** -observeValueForKeyPath:... only defined for abstract class
- From: Jerry Krinock <email@hidden>
- Date: Sun, 23 Sep 2007 16:55:26 -0700
I've added a custom control which displays data from a "detail" (as
in "master/detail") NSArrayController which it observes. That array
controller is in Entity mode, and this is a Core Data project.
Sometimes, while manipulating the control or the model data which is
bound into this array controller, I get the following message in the
console:
*** -observeValueForKeyPath:ofObject:change:context: only defined for
abstract class.
Define -[NSKeyValueObservance
observeValueForKeyPath:ofObject:change:context:]!
The method referred to there is is the workhorse which we use to
receive KVO notifications. It is defined in the "NSKeyValueObserving
Protocol Reference"
API. The protocol overview says that it is "provided" for "all
objects", although it is informal.
So, what might they mean "only defined for abstract class"?? The API
does not say anything about "abstract classes".
Thanks,
Jerry Krinock
More info. My project is a simple demo project with no non-Cocoa
frameworks. Searching the project for the offensive method, I've
confirmed that I've implemented it in two places...
The first implementation is in my custom control. This custom
control is a subclass of NSView, and it is observing the
'arrangedObjects' in the "detail" array controller, and also two keys
of the objects managed in the array controller, which it displays.
These objects are subclasses of NSManagedObject, and were generated
by mogenerator. I've read that 'arrangedObjects' may not be a good
key to observe since it is not KVC, but it seems to work, and is the
only way I can figure out to get notified of changes caused by a
changing filter predicate. (I suppose I could write my own KVC array
controller with the filtering and sorting features that I need
instead of using NSArrayController, but I'd like to avoid that if
possible.)
The second implementation is in my _AppDelegate, a subclass of
NSObject. It is observing the 'selectedObjects' of a "master" array
controller, so that it can setFilterPredicate: of the "detail" array
controller to only show objects "selected" in the master.
I keep track of the managed objects that the custom view observing by
means of an array ivar in my custom view. Whenever the array
changes, I remove the custom view as an observer of all the managed
objects, for the two keyPaths that I am observing, then repopulate
this array with the new managed objects as I add them to the view.
I've logged my invocations of addObserver:forKeyPath:options:context
and invocations of removeObserver:forKeyPath and verified that this
all seems to be working; i.e. all added observers are always removed
when the array changes.
_______________________________________________
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