More improvements to the managed object store and seeding API's

This commit is contained in:
Blake Watters
2011-03-05 17:05:31 -05:00
parent e07d87939f
commit 3cf66e5385
7 changed files with 43 additions and 12 deletions

View File

@@ -28,9 +28,6 @@
NSMutableArray* dateFormats = [[[mapper dateFormats] mutableCopy] autorelease];
[dateFormats addObject:@"E MMM d HH:mm:ss Z y"];
[mapper setDateFormats:dateFormats];
// Initialize object store
objectManager.objectStore = [[[RKManagedObjectStore alloc] initWithStoreFilename:@"RKTwitterData.sqlite"] autorelease];
// Add our element to object mappings
[mapper registerClass:[RKTUser class] forElementNamed:@"user"];
@@ -42,7 +39,7 @@
// This is what triggers the conditional compilation to cause the seed database to be built
// 2) Source JSON files are added to the 'Generate Seed Database' target to be copied into the bundle. This is required
// so that the object seeder can find the files when run in the simulator.
#ifdef RESTKIT_GENERATE_SEED_DB
#ifdef RESTKIT_GENERATE_SEED_DB
RKManagedObjectSeeder* seeder = [RKManagedObjectSeeder objectSeederWithObjectManager:objectManager];
// Seed the database with instances of RKTStatus from a snapshot of the RestKit Twitter timeline
@@ -57,7 +54,10 @@
// NOTE: If all of your mapped objects use element -> class registration, you can perform seeding in one line of code:
// [RKManagedObjectSeeder generateSeedDatabaseWithObjectManager:objectManager fromFiles:@"users.json", nil];
#endif
// Initialize object store
objectManager.objectStore = [RKManagedObjectStore objectStoreWithStoreFilename:@"RKTwitterData.sqlite" usingSeedDatabaseName:RKDefaultSeedDatabaseFileName managedObjectModel:nil];
// Create Window and View Controllers
RKTwitterViewController* viewController = [[[RKTwitterViewController alloc] initWithNibName:nil bundle:nil] autorelease];
UINavigationController* controller = [[UINavigationController alloc] initWithRootViewController:viewController];

Binary file not shown.

View File

@@ -41,6 +41,7 @@
25F2A1921322D59400A33DE4 /* MobileCoreServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8452D3FC128244E60069F4A9 /* MobileCoreServices.framework */; };
25F2A1991322D93500A33DE4 /* restkit.json in Resources */ = {isa = PBXBuildFile; fileRef = 25F2A1981322D93500A33DE4 /* restkit.json */; };
25F2A19C1322DD1800A33DE4 /* users.json in Resources */ = {isa = PBXBuildFile; fileRef = 25F2A19A1322DCDC00A33DE4 /* users.json */; };
25F2A24B1322EADE00A33DE4 /* RKSeedDatabase.sqlite in Resources */ = {isa = PBXBuildFile; fileRef = 25F2A24A1322EADE00A33DE4 /* RKSeedDatabase.sqlite */; };
288765A50DF7441C002DB57D /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 288765A40DF7441C002DB57D /* CoreGraphics.framework */; };
28D7ACF80DDB3853001CB0EB /* RKTwitterViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 28D7ACF70DDB3853001CB0EB /* RKTwitterViewController.m */; };
3F3CE34C125B95F60083FDCB /* libRestKitCoreData.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3F3CE2CF125B93780083FDCB /* libRestKitCoreData.a */; };
@@ -148,6 +149,7 @@
25F2A1961322D59400A33DE4 /* Generate Seed Database.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Generate Seed Database.app"; sourceTree = BUILT_PRODUCTS_DIR; };
25F2A1981322D93500A33DE4 /* restkit.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = restkit.json; sourceTree = SOURCE_ROOT; };
25F2A19A1322DCDC00A33DE4 /* users.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = users.json; path = ../users.json; sourceTree = "<group>"; };
25F2A24A1322EADE00A33DE4 /* RKSeedDatabase.sqlite */ = {isa = PBXFileReference; lastKnownFileType = file; path = RKSeedDatabase.sqlite; sourceTree = SOURCE_ROOT; };
288765A40DF7441C002DB57D /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
28D7ACF60DDB3853001CB0EB /* RKTwitterViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RKTwitterViewController.h; sourceTree = "<group>"; };
28D7ACF70DDB3853001CB0EB /* RKTwitterViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RKTwitterViewController.m; sourceTree = "<group>"; };
@@ -271,6 +273,7 @@
29B97317FDCFA39411CA2CEA /* Resources */ = {
isa = PBXGroup;
children = (
25F2A24A1322EADE00A33DE4 /* RKSeedDatabase.sqlite */,
25F2A19A1322DCDC00A33DE4 /* users.json */,
25F2A1981322D93500A33DE4 /* restkit.json */,
3F3CE40A125B9B450083FDCB /* BG.png */,
@@ -439,6 +442,7 @@
3F3CE40F125B9B450083FDCB /* BG@2x.png in Resources */,
3F3CE410125B9B450083FDCB /* Default.png in Resources */,
3F3CE411125B9B450083FDCB /* Default@2x.png in Resources */,
25F2A24B1322EADE00A33DE4 /* RKSeedDatabase.sqlite in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};