Skip to content

Instantly share code, notes, and snippets.

@JHumphreyJr
Created November 7, 2012 19:06
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save JHumphreyJr/4033674 to your computer and use it in GitHub Desktop.
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)
withObject:nil
waitUntilDone:NO];
//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;
}
@JHumphreyJr
Copy link
Author

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