Does NSFetchedResultsController Observe All Changes to Persistent Store?

前端 未结 2 671
渐次进展
渐次进展 2021-01-12 13:21

My program does work like link below:

Update results of NSFetchedResultsController without a new fetch

  1. show result of NSFetchedResultsController to UIT
相关标签:
2条回答
  • 2021-01-12 14:14

    I'm sorry to my mistake, I tested with new test project.

    CoreData DOES full-tracking of whole persistent store.

    This means, if new object that is suitable to predicate of NSFetchedResultsController, delegate will notify it.

    0 讨论(0)
  • 2021-01-12 14:18

    I thought NSFetchedResultController watches all changes in persistent store, is it too big hope?

    The FRC only automatically observes the objects returned by its fetch. This is normally not a problem as changes to objects monitored by an FRC should arise from either the tableview UI or a background context. In the former, the FRC is alerted to the change and in the latter, merging the foreground and background context will trigger the FRC to update.

    It sounds like you've got code changing values but you're not notifying the FRC that you've made any changes. (If you got a tableview displaying all objects whose isMyTest == TRUE then obviously you can't access objects from the UI whose isMyTest == FALSE.) In that case, you need to register the tableview controller for:

    NSManagedObjectContextObjectsDidChangeNotification
    

    … notifications from the context so that you can tell the FRC to update for changes made outside its observation.

    0 讨论(0)
提交回复
热议问题