Question

I am using Core Data to save a bunch of information.

Lets say I have option for 3 different saves in a game. If the user selects SaveGame1, it loads SavedGameStore1. If the user selects SaveGame2, it loads SavedGamedStore2.

They all contain the same Entities.

I don't need to transfer information from one Store to another Store.

My understanding of the Persistent Stores and Persistent Store Coordinator is a bit shaky.

I am using Magical Record.

In the appDelegate:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    // Override point for customization after application launch.

    [MagicalRecord setupAutoMigratingCoreDataStack];
}

Magical Record has a method setupCoreDataStackWithSotreNamed:.

Is it as simple as after the user makes his selection, just call that method? That would switch it from the default store to my SavedGameStore1?

Was it helpful?

Solution

That should be correct. You'll want to (carefully) call [MagicalRecord cleanUp] to tear down the existing core data stack before loading in a new one with [MagicalRecord setupCoreDataStackWithStoreNamed:].

I wonder if you can't put all the save game data into a single store? Could you add an additional entity with relationships to the save game data? This will likely simplify things...

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top