On Aug 30, 2008, at 14:23, Alex Duzik wrote:

I'm writing an app where one Core Data entity -- Folder -- has (conceptually) a to-many relationship with another object -- Item. But I want to keep those items in a particular order, so I have a third entity, OrderedItem, which keeps a reference to the folder along with a reference to the item and also adds an order attribute to track the item's position in the folder.

This is rather cumbersome to maintain, so I've implemented the key- value coding methods for a to-many relationship:

- (NSUInteger) countOfItems
- (Item *)objectInItemsAtIndex:(NSUInteger)index;
- (void)insertObject:(Item *)item inObjectsAtIndex:(NSUInteger)index;
- (void)removeObjectFromItemsAtIndex:(NSUInteger)index;

The 3rd method should be insertObject:inItemsAtIndex:, so your "items" property isn't fully KVC compliant.

You might want to consider, as an alternative, putting the order attribute directly in the Item entity, and get a sorted array using a fetch request.


_______________________________________________

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 [EMAIL PROTECTED]

Reply via email to