Core Data: data model versioning problem
Core Data: data model versioning problem
- Subject: Core Data: data model versioning problem
- From: "Cocoa Developer" <email@hidden>
- Date: Mon, 27 Nov 2006 16:41:38 +0200
Hello there,
I am trying to implement data model versioning as described in
http://developer.apple.com/documentation/Cocoa/Conceptual/CoreData/Articles/cdVersioning.html#//apple_ref/doc/uid/TP40002989
.
My current store type is SQLite.
I am performing following actions to create and load data with old model:
NSError *error;
NSString *oldModelName = @"MyDocument";
NSURL *oldModelURL = [NSURL fileURLWithPath:[[NSBundle mainBundle]
pathForResource:oldModelName ofType:@"mom"]];
NSManagedObjectModel *oldModel = [[NSManagedObjectModel alloc]
initWithContentsOfURL:oldModelURL];
NSPersistentStoreCoordinator *oldCoordinator =
[[NSPersistentStoreCoordinator alloc]
initWithManagedObjectModel:oldModel];
id oldStore = [oldCoordinator
addPersistentStoreWithType:NSSQLiteStoreType configuration:nil
URL:[NSURL fileURLWithPath:__PATH_TO_FILE] options:nil error:& error];
if (error != nil) NSLog(@"ERROR");
NSAssert(oldStore != nil, ([NSString stringWithFormat:@"Error
initializing old store: %@", error]));
/////
NSManagedObjectContext *oldContext = [[NSManagedObjectContext alloc] init];
[oldContext setPersistentStoreCoordinator:oldCoordinator];
NSFetchRequest *oldObjectFetchRequest = [[[NSFetchRequest alloc] init]
autorelease];
[oldObjectFetchRequest setEntity:[NSEntityDescription
entityForName:@"MyOldEntity" inManagedObjectContext:oldContext]];
NSArray *oldObjects = [oldContext
executeFetchRequest:oldObjectFetchRequest error:& error];
if (error != nil)
{
NSLog(@"old objects count: %d", [oldObjects count]);
int ijk = 0;
for (ijk = 0; ijk < [oldObjects count]; ijk++)
{
///
}
}
The problem is at "NSArray *oldObjects = [oldContext
executeFetchRequest:oldObjectFetchRequest error:& error];" line. When
running program with debugger, it allways stops on it. No crash. By
why does it stops here? And of course the following code after this
line is not executed.
Could someone point me what am I doing wrong? Thank you for any answers.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden