2

I am working on app which has 2 entities, Course and Schedule where Course has a to-many relationship to Schedule. One Course can have many schedules. On my tableview i am displaying the course name and the total number of hours scheduled for that course. lets Say course schedule 1 for course A is 9 am to 11 am and schedule 2 for course A 2 pm to 6 pm. the total is 6. If i change the course name in any way the nsfetchResults controller detects the change and trigers the 'controller:didchangeobject:..." However, if i change the starting or ending time for my schedule the nsFetchresultsController wont get triggered and the tableview wont reload unless i do [self.tableview relodData]. Is this the best way of reloading tableview. should the nsfetchresultscontroller be triggering. if you can lead me to the right direction that would be great. Please let me know if you need more information as I am a noob @ core data and 1st question on SO.

Thanks in Advance guys.

Daelhoser
  • 97
  • 2
  • 7

1 Answers1

1

The FRC isn't triggering because it is only monitoring the Course objects for changes (because that is the fetch request it has). You can't change that because the fetch only has a single entity.

If you always know when the Schedules get updated then your current solution and reloading is fine. If not, you can add your controller as an observer of the managed object context and then process all change notifications to decide if you should reload.

Wain
  • 118,658
  • 15
  • 128
  • 151
  • Wain @Wain, cheers, you may possibly have a take on this issue: https://stackoverflow.com/questions/60277521/how-to-touch-a-core-data-entity-to-trigger-nsfetchedresultscontroller – Fattie Feb 29 '20 at 14:06