Skip to content

Instantly share code, notes, and snippets.

@blakewatters
Created January 25, 2011 15:19
Show Gist options
  • Save blakewatters/795054 to your computer and use it in GitHub Desktop.
Save blakewatters/795054 to your computer and use it in GitHub Desktop.
// This is typically configured as a secondary target on your project
// Dump your seed data out of your backend system in JSON format
// Add to the project as resources
// Run the secondary target in the Simulator
- (void)seedTheDatabase {
// Setup the object manager
RKObjectManager* objectManager = [RKObjectManager objectManagerWithBaseURL:@"http://restkit.org"];
objectManager.objectStore = [[RKManagedObjectStore alloc] initWithStoreFilename:@"ContactsSeed.sqlite"];
// Load all the data from the file contacts.json into a seed database
// The seeder will print instructions for how to copy the data to your app
RKObjectSeeder* seeder = [[RKObjectSeeder alloc] initWithObjectManager:objectManager];
[seeder seedDatabaseWithBundledFile:@"contacts" ofType:"json"];
[seeder finalizeSeedingAndExit];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment