G'day All
I'm working on a CoreData driven app which starts with an empty CoreData store that I populate from a StackMob application.
I have a subclass of UITableView that fetches & presents my data as I want it to but I'm a bit puzzled about when I should best go get the initial data from StackMob. When I triggered populating my CoreData store (from a small plist file & only for testing the view) in applicationDidFinishLaunching my app spent an long time displaying the default screen & I expect that will be even longer with real data fetched from the web. I'm considering changing this method on my UITableView sub-class...
- (NSFetchedResultsController *)frc
{
if (_frc) return _frc;
...
return _frc;
}
to...
- (NSFetchedResultsController *)frc
{
if (_frc) return _frc;
...
if ([[_frc fetchedObjects] count] == 0) {
// Spawn NSOperation to get initial data from StackMob.
// & use it to populate my CoreData store.
}
return _frc;
}
in which case I'd make the NSOperation a sub-class that I could re-use for subsequent data updates.
I'm checking with [[_frc fetchedObjects] count] == 0
because I'm fetching all data from the entity.
Is a good approach to take? If not what would be a better approach?
I'm hoping to provode a user experience like I've seen on some apps I use where item appear on the 'home' screen as it is downloaded & added to the CoreData store.
Cheers & TIA, Pedro :)