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 <rm...@latencyzero.com> 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 (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: > https://lists.apple.com/mailman/options/cocoa-dev/himself%40sfko.com > > This email sent to hims...@sfko.com > _______________________________________________ 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com