Re: NSFetchedResultsController sort on synthesized property?
Re: NSFetchedResultsController sort on synthesized property?
- Subject: Re: NSFetchedResultsController sort on synthesized property?
- From: Sixten Otto <email@hidden>
- Date: Thu, 27 Feb 2014 07:14:35 -0700
The fetched results controller needs to be able to do its sorting in the
database (assuming a SQLite store). The section keypath itself doesn't
necessarily need to be a persistent property, as long as its values match
the ordering of the sort descriptors. (For instance: a table that sections
the results by day might have a transient property that calculates the day
from the date, but actually sorts the results by the persistent date
property.)
Sixten
On Wed, Feb 26, 2014 at 9:21 PM, Rick Mann <email@hidden> wrote:
> It seems that I can't sort on a read-only synthesized property in my
> NSManagedObject subclass. I'd like to sort a bunch of stuff into some
> sections, but the definition of a section is somewhat complex, depending on
> multiple other properties. So, I defined a property "section" like this:
>
> - (NSUInteger)
> section
> {
> if (self.active.boolValue)
> {
> return 1;
> }
> else if (self.dateClosed != nil)
> {
> return 3;
> }
> else
> {
> return 2;
> }
> }
>
> + (NSSet*)
> keyPathsForValuesAffectingSection
> {
> return [NSSet setWithObjects: @"active", @"dateClosed", nil];
> }
>
> I similarly define a "sectionName" property, but the
> NSFetchedResultsController has no problem using that to section the table
> view.
>
> Unfortunately, I get an exception when I attempt to execute the fetch
> while sorting on "section". Is there any way to accomplish what I need?
>
>
> --
> Rick
>
>
>
>
> _______________________________________________
>
> 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
>
_______________________________________________
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