To subsequently add new objects, etc., you want to use version control and the automatic easy migration described here:
http://developer.apple.com/iphone/library/documentation/Cocoa/Conceptual/CoreDataVersioning/Articles/vmLightweight.html#//apple_ref/doc/uid/TP40008426-SW1
Basically, you create a new version of your data model using the Design->Data Model menu Design->Data Model in Xcode, and then make a few code changes. This will cause Core Data to automatically migrate the older model to the newer one. You are limited by what changes you can make. You can add new entities and add an additional attribute to existing objects or the required attributes with the default values set.
One thing that caught me is that the way you load the NSManagedObjectModel master data changes when you want to use version control and migration. Without migration, you probably have the following:
NSManagedObjectModel *model = [NSManagedObjectModel mergedModelFromBundles:nil];
Once you start using version control and migration, you need to change something like this:
NSString *path = [[NSBundle bundleForClass:self.class] pathForResource:@"DataModelName" ofType:@"momd"]; NSURL *url = [NSURL fileURLWithPath:path]; NSManagedObjectModel *model = [[[NSManagedObjectModel alloc] initWithContentsOfURL:url] autorelease];
source share