Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Core Data Migration Scenario
//Delayed method to prevent core
- (void)delayedMagicalRecordSetup
[MagicalRecord setupAutoMigratingDefaultCoreDataStack];
//Now core data can be used and the windows root view controller
// can be changed to a view controller that may need access to MagicRecord
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
//Use a simple splash screen that makes no database connections until migrations are complete.
SplashViewController *splash = [[SplashViewController alloc] initWithNibName:nil bundle:nil];
self.window.rootViewController = splash;
[self.window makeKeyAndVisible];
//This is necessary to delay any migrations to the next run loop
[self performSelectorOnMainThread:@selector(delayedMagicalRecordSetup)
//IT IS IMPORTANT that developers do not include any code that calls Core Data
//This needs to return YES within a reasonable amount of time
// My testing shows ~24 seconds
return YES;

This comment has been minimized.

Copy link
Owner Author

JHumphreyJr commented Nov 7, 2012

Gist is related to the discussion on magicalpanda/MagicalRecord#301.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.