I created an iPhone app using XCode's Navigation-based Application template, which creates the Core Data infrastructure in the generated code.
I replaced the generated Event entity with my own Company entity. All the database infomation shows up in the viewTable. So far so good.
Now I create a second entity called Group and I use the one viewTable to show both data sets, depending on a toggle switch setting:
- The viewTable is able to switch between the two sets of data ok if the data is retrieved from a database directly.
- It is also able to display the data from Core Data properly for the table that is shown upon initialization, whichever table I set that to.
But, with Core Data, when I use the switch to toggle tables, the data isn't updated. I don't think this isn't about reloadData since I had that working ok with data from the database. Actually, the numberOfSections is 0 so the data just isn't being retrieved.
I tried printing out the internal calls to the database to figure out what's going on. It seems that the database calls are being invoked just after the fetchedResultsController method and just before the numberOfSectionsInTableView. (Does Core Data run in a background thread but is then synchronized with the main thread?) After I switch from Company to Group, fetchedResultsController is called again but, this time, there are no database calls made before numberOfSectionsInTableView is called.
Although Core Data seems to save some coding compared to sqlite, I feel lost because I can't see where the things are happening. How do I can my hands on the invocation to the database so I can force a fetch?
Anyone have any ideas?
Thanks!