• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
+keyPathsForValuesAffecting<Key> not working for a category-implemented property on a CoreData class
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

+keyPathsForValuesAffecting<Key> not working for a category-implemented property on a CoreData class


  • Subject: +keyPathsForValuesAffecting<Key> not working for a category-implemented property on a CoreData class
  • From: Doug Knowles <email@hidden>
  • Date: Thu, 17 Sep 2009 08:44:56 -0400

I'm having trouble defining this briefly.
I am using CoreData-generated classes, and extending them by defining
methods and calculated properties in categories on the generated classes (so
they don't get overridden if I regenerate the classes). All works fine for
properties with CoreData-defined types (scalars, strings, etc.), but not for
some hackery I'm using for properties with other types.

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.

This all works up to a point: for example, NSArray *children =
aTopic.orderedChildren; works fine.

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.)

All this works on a category-implemented, transient, optional string
attribute on Topic. The only difference is the hackery around UNKNOWN_TYPE,
and I'm not sure I understand why that should make a difference.

Should I file a bug, or am I off-base?

Or is there a better way to wrap CoreData classes?

TIA,
Doug K;
_______________________________________________

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

  • Follow-Ups:
    • Re: +keyPathsForValuesAffecting<Key> not working for a category-implemented property on a CoreData class
      • From: Quincey Morris <email@hidden>
  • Prev by Date: Re: getline 'free' problem
  • Next by Date: -NSMutableIndexSet shiftIndexesStartingAtIndex:by: weirdness
  • Previous by thread: Fwd: [SOLVED] NSTreeController setSelectionIndexPath depends on sort order
  • Next by thread: Re: +keyPathsForValuesAffecting<Key> not working for a category-implemented property on a CoreData class
  • Index(es):
    • Date
    • Thread