Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iPhone - Cache name for NSFetchedResultsController

G'day Folks

My CoreData driven app has a number of views of data from the same store & all using an NSFetchedResultsController. Currently they all have the same name for the NSFetchedResultsController cache, "Root". Users of my app can, & probably will, jump indiscriminately between views. Would it be better for user experience if I gave the cache for each NSFetchedResultsController a unique name?

TIA, Pedro :)

like image 735
Pedro Avatar asked Nov 28 '10 05:11

Pedro


People also ask

What is Persistentcontainer in Swift?

NSPersistentContainer simplifies the creation and management of the Core Data stack by handling the creation of the managed object model ( NSManagedObjectModel ), persistent store coordinator ( NSPersistentStoreCoordinator ), and the managed object context ( NSManagedObjectContext ).

When should we use NSFetchedResultsController class?

NSFetchedResultsController is a very useful class provided by the CoreData framework. It solves many performance issues you frequently run into while reading a large amount of data from database and displaying that data using a UITableview, UICollectionView or MKMapView.

What is NSManagedObjectContext in Swift?

An object space to manipulate and track changes to managed objects.

What is fetchedresultscontroller?

The fetched results controller efficiently analyzes the result of the fetch request and computes all the information about sections in the result set. It also computes all the information for the index based on the result set.


1 Answers

Providing a different cache name for different fetches is advisable and will help with performance.

From Apple documentation at http://developer.apple.com/library/ios/documentation/CoreData/Reference/NSFetchedResultsController_Class/Reference/Reference.html#//apple_ref/doc/uid/TP40008227-CH1-SW24

If you have multiple fetched results controllers with different configurations (different sort descriptors and so on), you must give each a different cache name.

Cheers, Rog

like image 152
Rog Avatar answered Sep 30 '22 15:09

Rog