MKD
MKD

Reputation: 91

NSFetchedResultsController (Core Data) does NOT provide correct data source Table View Controller

I had encountered a challenge recently. I would really appreciate that anyone could provide any support.

The issue: NSFetchedResultsController (Core Data) does NOT provide correct data source Table View Controller.

What I am trying to achieve:

What works:

What error do I get:

What have I done that does not work:

What do I think the direction of the solution:

Summary:

I would like to know how to overcome the printed error so that I could add a new row into the Table View with Core Data database feeding the right amount of objects from the managedObjectContext.

Solution:

Implement the NSFetchedResultsControllerDelegate, and let it to fully control the CRUD flow for the Table View, rather than calling regular table view row inserting, deleting methods outside of the NSFetchedResultsControllerDelegate' methods, because Core Data's NSFetchedResultsController is acting as the data source.

Thanks a lot

Regards,

张靖元(Jingyuan Knight Zhang)

Upvotes: 3

Views: 403

Answers (1)

MKD
MKD

Reputation: 91

Solution:

Implement the NSFetchedResultsControllerDelegate, and let it to fully control the CRUD flow for the Table View, rather than calling regular table view row inserting, deleting methods outside of the NSFetchedResultsControllerDelegate' methods, because Core Data's NSFetchedResultsController is acting as the data source.

Upvotes: 4

Related Questions