Need help sorting with NSSortDescriptor and/or/NSPredicate (Core Data)
Need help sorting with NSSortDescriptor and/or/NSPredicate (Core Data)
- Subject: Need help sorting with NSSortDescriptor and/or/NSPredicate (Core Data)
- From: Michael Crawford <email@hidden>
- Date: Mon, 07 Feb 2011 09:56:18 -0500
I'm trying to implement a feature where I sort a cross-section of music from multiple genres with up to two different keys, where the items with a genre matching the first key appear first in the collection and items with a genre matching the second key appear after the first group in the collection. All songs with a genre not matching the first or second keys can be in any order following the first two groups.
So I took a look at NSSortDescriptor but it is not apparent to me how I would accomplish my goal with this class. If I sort with it based on the genre key, will basically sort them in alphabetical ascending or descending order, not what I want.
It seems what I really need to do is modify my predicate so that I issue a query for the first group. And then issue another separate query for the second group, and finally a third query for the remaining items where the genre is not a match for the first or second group.
Three queries just to get this sorted collection. I'm not experienced with NSSortDescriptor and I've only used very simple expressions with NSPredicate. Is there a way to get what I want with a single Core Data fetch-request?
-Michael
_______________________________________________
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