Correctly use of NSFetchedResultsController cache

Viewed 4732

I am using a NSFetchedResultsController for dealing with a UITableView and everything works fine and I found it very powerful, especially in conjunction with the results delegate. For drilling down the table I am reusing the same controller class, which get instantiated with parameters by clicking on a cell row, the controller is then pushed to the UINavigationController and another table view is built, again with a NSFetchedResultsController.

At this point, every controller has its own cache, and the cache name is derived with a unique identifier [NSString stringWithFormat"cacheName_%@",uniqueStringForCell], and in the end I can obviously have many cache.

Now the questions.

1) Having many cache can be a problem ?

2) When are we supposed to use a cache ?

3) In case of deleteCacheWithName , where's the best place to put such method ? I have tried in viewWillDisappear, but with this I suppose I can have problem when the view will appear again and the cache is not present anymore, for example when using with a UINavigationController. Probably the dealloc method is the best place ?

4) What's the relationship between a cache and memory management ? I mean, when a (void)didReceiveMemoryWarning is sent do I need to delete the cache ? If yes, what about rebuilding it again ? What's the preferred way, maybe re issuing the fetch ?

5) the fetch controller has its delegate set to the UITableViewController (fetchController.delegate=self), is there any problem with that ? In a sense that in case of change more than one controllers is alerted ? And does deleteCacheWithName also remove the delegate ?

thanks

1 Answers
Related