In data model I have transient property uppercaseFirstLetterOfName
which will return first letter of persistent property. I specify this property in
NSSortDescriptor* sortByWordDescriptor = [[NSSortDescriptor alloc]
initWithKey:@"subject" ascending:YES];
NSArray* sortArray = [[NSArray alloc]
initWithObjects:sortByWordDescriptor, nil];
[fetchRequest setSortDescriptors:sortArray];
NSFetchedResultsController* controller = [[NSFetchedResultsController alloc]
initWithFetchRequest:fetchRequest
managedObjectContext:managedObjectContext
sectionNameKeyPath:@"uppercaseFirstLetterOfName"
cacheName:@"Root"];
When I change the persistent object taken from fetchedresultscontroller so the section should be deleted, only controller:didChangeObject
fires. But since the section is gone(in fact) I would expect controller:didChangeSection
also be fired. Should I do something extra when modifying persistent object in order to make controller:didChangeSection
invoked?
UPD:
This is transient property getter in model subclass
- (NSString *)uppercaseFirstLetterOfName
{
[self willAccessValueForKey:@"uppercaseFirstLetterOfName"];
NSString *aString = [[self valueForKey:@"subject"] uppercaseString];
NSString *stringToReturn = [aString substringWithRange:
[aString rangeOfComposedCharacterSequenceAtIndex:0]];
[self didAccessValueForKey:@"uppercaseFirstLetterOfName"];
return stringToReturn;
}
Here I get the object and pass to view controller to modify
...
detailViewController.unit = (ModelClass*)[fetchedResultsController
objectAtIndexPath:indexPath];
...
and finally data modification
unit.subject = someTextField.text;
...
[unit.managedObjectContext save:&error]
I don't have anything other special for transient object, so I don't modify it directly.