views:

8

answers:

2

Hello,

I would like to know if I can do this

VIEW 1: use NSFetchedResultsController on TABLEA to retrieve the data, display in a table view and take actions to save it

    NSFetchedResultsController *aFetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest managedObjectContext:referringObject sectionNameKeyPath:nil cacheName:@"TABLEA"];

and then in VIEW 2 use NSFetchedResultsController on the SAME table i.e. TABLEA to retrieve the data without table view and go back to VIEW 1 to save that previous managed object ??

A: 

They will return the same managed objects provided you use the same managed object context.

tc.
+1  A: 

TABLEA is not an SQL table. Core Data is not SQL. In this case, TABLEA is just the fetched results controller's (FRC) cache file. Passing the same cache between controllers would do nothing because as soon as you changed anything, the cache would refresh itself anyway. You can in principle pass the FRC itself but this is never done because it gets messy.

Managed object instances are attached to managed object contexts and not to fetches or fetched results controller. If you want to pass a managed object between view controllers you pass the object itself. If you want to save the context in different controllers then you pass the context as well. The fetches don't enter into it.

Fetches/FRC are usually specific to a particular view-controller because each view-controller needs to display a specific subset of data in a specific sort order so each view-controller needs to customize its own fetch.

TechZen
Thankyou for the detailed explanation.
Accilies