timothyarmes / TAFetchedResultsController

A version of NSFetchedResultsController that provides for having empty sections
MIT License
43 stars 7 forks source link

Add ability to use keypath of the managed object as section grouping #10

Open swm93 opened 6 years ago

swm93 commented 6 years ago

Currently, the section grouping keypath must reference a value on the section managed object. This change allows the section grouping keypath to be a keypath on the section managed object.

Example

Currently, using the sectionGroupingKeyPath section.uuid is valid because uuid is a value on the section managed object.

TAFetchedResultsController *taFetchedResultsController = [[TAFetchedResultsController alloc] initWithItemFetchRequest:itemFetchRequest
    sectionFetchRequest:sectionFetchRequest
    managedObjectContext:self.managedObjectContext
    sectionGroupingKeyPath:@"section.uuid"
    cacheName:nil];

However, if section.uuid was section.subsection.uuid an error would be thrown because we would attempt to find the value uuid on the section managed object. Instead, we now look for the keypath subsection.uuid on the section managed object.

TAFetchedResultsController *taFetchedResultsController = [[TAFetchedResultsController alloc] initWithItemFetchRequest:itemFetchRequest
    sectionFetchRequest:sectionFetchRequest
    managedObjectContext:self.managedObjectContext
    sectionGroupingKeyPath:@"section.uuid"
    cacheName:nil];