Thanks for the help; all better now. Comments inline. On Thu, Sep 17, 2009 at 12:42 PM, Quincey Morris < quinceymor...@earthlink.net> wrote:
> On Sep 17, 2009, at 05:44, Doug Knowles wrote: > > In a CoreData entity called "Topic", I have a to-many relationship (to >> other >> Topics) called "children" to implement a hierarchy. In a category on >> Topic, >> I have implemented a property called "orderedChildren" which returns a >> sorted array of the children. In order to ensure that "orderedChildren" is >> recognized as a property of the Topic entity, I have defined >> "orderedChildren" as an optional, transient attribute of Topic of unknown >> type (since NSArray or id isn't supported). CoreData generates a property >> declaration for ""orderedChildren" with type UNKNOWN_TYPE, and I have >> #defined UNKNOWN_TYPE as "id" in my precompiled header. >> > > It's not at all obvious that following this strategy (creating the > transient attribute) does you any good whatsoever. OTOH, it's not at all > obvious that it does any harm WRT to the problem you're having. I did this in a misguided attempt to eliminate a unimplemented method warning, which was properly fixed by including the category's header. > > What doesn't work is defining a class method >> +keyPathsForValuesAffectingOrderedChildren, >> which I'd like to use to cause changes in the "children" relationship to >> trigger change notifications for "orderedChildren". >> keyPathsForValuesAffectingOrderedChildren is never called. (Overriding >> keyPathsForValuesAffectingValueForKey: from a category is verboten.) >> > > Prima facie, the reason 'keyPathsForValuesAffectingOrderedChildren' doesn't > get called would be that nothing is observing the property. Maybe that > aspect deserves attention ahead of the Core Data side of it. Have you tried > writing some debugging code that (a) installs a KVO observer on the > "orderedChildren" property of a Topic object, and (b) changes the "children" > property, to see whether (c) "observeValueForKeyPath:..." is invoked for key > "orderedChildren"? > Sigh, And thereby hangs the problem: the observer I thought I added was missing. Adding the observer back yields the expected results, and keyPathsForValuesAffectingOrderedChildren is being called. > > Narrowing the problem definition might be the most useful thing you could > do. > > Also, sorry if it's a stupid question, but you have checked the console log > for exception messages, haven't you? It often happens, with KVO-related > problems, that an application can appear to run *almost* correctly after an > exception is logged and ignored. > > There are no stupid questions, especially from people like yourself willing to lend some assistance here. In this case, I have a "permanent" (if sometimes disabled) on objc_exception_throw that I use to help make sure I don't miss exceptions. Many thanks again. _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com