0

I have a NSFetchedResultsController with section names that may change without any actual changes to the NSFetchedResultsControllers' fetch request entity.

Is there a way to observe changes to the sectionnamekeypath so that a UITableView section name will update when one of the names of the NSFetchedResultsControllers' sections is updated?

EDIT: I use the transient property listNameSectionHeader, below, as the sectionNameKeyPath. When a list.name changes, the section header for that list.name does not change accordingly, and I am not sure why.

- (NSString*)listNameSectionHeader {

    __ENTERING_METHOD__
    [self willAccessValueForKey:@"listNameSectionHeader"];
    NSString *listNameSectionHeader = [self primitiveValueForKey:@"listNameSectionHeader"];
    [self didAccessValueForKey:@"listNameSectionHeader"];
    if (listNameSectionHeader == nil) {
        listNameSectionHeader = [self recalculateListNameSectionHeader];
    }
    return listNameSectionHeader;
}
- (NSString*)recalculateListNameSectionHeader {

    __ENTERING_METHOD__
    NSString *listNameSectionHeader = self.list.name;
    [self setListNameSectionHeader:listNameSectionHeader];
    return listNameSectionHeader;
}
D4ttatraya
  • 3,344
  • 1
  • 28
  • 50
SAHM
  • 4,078
  • 7
  • 41
  • 77
  • Are you storing section names outside the fetch request entity? If so, try to save it in fetch request entity OR else make it computational(transient) depending on saved property. – D4ttatraya Mar 24 '16 at 08:36
  • I made the sectionNameKeyPath a transient property (based on another entity's attribute), but when the transient property changes, the section header does not refresh. I thought it should - I am so confused. – SAHM Mar 25 '16 at 01:30
  • How are making it transient? plz check this answer [stack link](http://stackoverflow.com/questions/24729190/core-data-transient-values-with-swift/36162207#36162207) – D4ttatraya Mar 25 '16 at 10:27

0 Answers0