Re: Need help sorting with NSSortDescriptor and/or/NSPredicate (Core Data)
Re: Need help sorting with NSSortDescriptor and/or/NSPredicate (Core Data)
- Subject: Re: Need help sorting with NSSortDescriptor and/or/NSPredicate (Core Data)
- From: Ken Thomases <email@hidden>
- Date: Fri, 11 Feb 2011 09:33:44 -0600
On Feb 11, 2011, at 9:19 AM, Michael Crawford wrote:
> Thank you both for your suggestions.
You're welcome. I'm glad I could help.
> I ended up going with Ken's idea regarding the synthetic property. It was added to a NSManagedObject derived class so I couldn't use it during the fetch request without actually adding an attribute but I did use it to sort the resulting array. The synthetic property computes an priority index when invoked. It performs very well.
By the way, I neglected to mention that you should also implement +keyPathsForValuesAffecting<Key> for your synthetic property returning the set of key paths which affect its value (e.g. the genre property). That's necessary for the synthetic property to be properly KVO-compliant. This should be standard operating procedure for all synthetic/derived properties.
Cheers,
Ken
_______________________________________________
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