My Core Data model has two entities: Author
and Book
with a To-Many relationship (one author->many books). In the main view I display a list of
Generally you should not need to save the changes if you are dealing with a single NSManagedObjectContext
for both the NSFetchedResultsController
and the UIViewController
that is making the changes.
That does not apply if you have more than one NSManagedObjectContext
.
Assuming you have one NSManagedObjectContext
, I would make sure you have the delegate set on the NSFetchedResultsController
and put break points in the delegate methods to see if you are getting any callbacks at all.
I would also use the debugger and print out the pointers for the NSManagedObject(s) you are working with and make sure they are the same. If they are not then it would point to an issue with the NSManagedObjectContext
.
Hmmm, still a little fuzzy. Are you saying the number of sections is incorrect?
Based on your code posted you are simply retrieving the NSManagedObject
instances from the NSFetchedResultsController
. Perhaps there is some confusion as to what that is?
The NSFetchedResultsController
is merely a container that has one or more sections. Those sections are also just a container that holds one or more NSManagedObject instances. Those are the same instances of NSManagedObject
that you would access anywhere else in your application (assuming a single NSManagedObjectContext
design).
Therefore if you change the data in a NSManagedObject
anywhere in your application it will be updated in the NSFetchedResultsController
because it is the same object, not a copy but the exact same object.
So this leads to a couple of questions:
-[UITableViewDatasource tableView: titleForHeaderInSection:]
is firing after you return from the edit?NSFetchedResultsControllerDelegate
methods are firing upon the return?Are you implementing -controller: didChangeSection: atIndex: forChangeType:
? If not, please do so and tell me if it fires. If it does fire, when does it fire? Before or after the call to -[UITableViewDatasource tableView: titleForHeaderInSection:]
?
This is starting to sound like an Apple bug.
A couple of thoughts: