Reloading UITableView after NSOperation Completes
I have a UITableViewController that creates an NSOperation to download data from the web. That 1st data is then used to download a 2nd data which performs a SQL SUM on another table and returns it. In the meantime the table view finishes its drawing of the cells and its content.
PROBLEM: If I try to use the 2nd array that will be completed after the NSOperation finishes, in the cellForRowAtIndexPath (CFRAIP) method, the app crashes because the array is empty.
ALTERNATIVES:
A) Ive been thinking of filling the 2nd array with dummy data at first and after the NSOperation finishes it can erase that array and populate it with the data it got from the web and proceed to reload the table view. So Ive been thinking of setting a BOOL dummyData=YES when the CFRAIP first loads, and after the NSOperation completes, set it to NO and then reload the data. The BOOL will tell me if the original dummyData has been replaced with the fresh actual data.
B) Download the complete dataset onto my app, add CoreData to it, then just hold off the loading of the entire tableview until I have the fetchedResultsController to load my CFRAIP method.
|