Core Data Migration Scenario
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Gist is related to the discussion on magicalpanda/MagicalRecord#301.