Note that there are some explanatory texts on larger screens.

plurals
  1. POCore Data context and singleton data controller
    primarykey
    data
    text
    <p>I have a singleton data controller to hold an array of objects. See for example bananas question for my solution: <a href="https://stackoverflow.com/questions/6324732/using-a-singleton-to-create-an-array-accessible-by-multiple-views">singelton dataController banansArray</a></p> <p>Now I want to save the array of bananas to persistant state. This core data tutorial: <a href="http://klanguedoc.hubpages.com/hub/Core-Data-How-To-Store-and-Display-Images-in-a-Core-Data-iPhone-App-iOS-iPad" rel="nofollow noreferrer">core data - store images</a> have given me a good general understanding of Core Data and I was able to include it in my application before changing my data Controller to singleton. </p> <p>Now what is best? </p> <p>Do I need to move the generated Core Data stack within the application delegate to the singletonDataController that manage the bananas array? Or do I have to set the context of the singleton in the application delegate as you do in the generated Master-View controller with Core Data template? </p> <p>In that case how do I set the context in the appDelegate? This does not work (it workes for the masterView in template) in the AppDelegate application <code>didFinishLaunchingWithOptions:</code></p> <pre><code>DataControllerSingleton *dataController; dataController.managedObjectContext = self.managedObjectContext; </code></pre> <p>In beerDataModel example provided the ManagedObjectCode is: </p> <pre><code>if (_mainContext == nil) { _mainContext = [[NSManagedObjectContext alloc] init]; _mainContext.persistentStoreCoordinator = [self persistentStoreCoordinator]; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload