• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: [Leopard] Core Data model versioning vs. NSPersistentDocument
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Leopard] Core Data model versioning vs. NSPersistentDocument


  • Subject: Re: [Leopard] Core Data model versioning vs. NSPersistentDocument
  • From: Pierre Bernard <email@hidden>
  • Date: Thu, 1 Nov 2007 15:27:59 +0100

Hi!

Thanks Malcolm.

I got at least one step closer to the solution, still it does not work yet.

Here is where I pass the appropriate option to the store coordinator:

- (BOOL)configurePersistentStoreCoordinatorForURL:(NSURL *)url
ofType:(NSString *)fileType
modelConfiguration:(NSString *)configuration
storeOptions:(NSDictionary *)storeOptions
error:(NSError **)error
{
NSMutableDictionary *options = [NSMutableDictionary dictionaryWithDictionary:storeOptions];

[options setObject:[NSNumber numberWithBool:YES] forKey:NSMigratePersistentStoresAutomaticallyOption];


BOOL ok = [super configurePersistentStoreCoordinatorForURL:url
ofType:fileType
modelConfiguration:configuration
storeOptions:options
error:error];

if (*error != nil) {
NSLog(@"sourceModel: %@", [[*error userInfo] valueForKeyPath:@"sourceModel.versionIdentifiers"]);
NSLog(@"destinationModel: %@", [[*error userInfo] valueForKeyPath:@"destinationModel.versionIdentifiers"]);
NSLog(@"same model: %@", ([[*error userInfo] valueForKeyPath:@"sourceModel"] == [[*error userInfo] valueForKeyPath:@"destinationModel"]) ? @"YES" : @"NO");
NSLog(@"equivalent model: %@", ([[[*error userInfo] valueForKeyPath:@"sourceModel"] isEqual:[[*error userInfo] valueForKeyPath:@"destinationModel"]]) ? @"YES" : @"NO");
NSLog(@"reason: %@", [[*error userInfo] valueForKeyPath:@"reason"]);


	}

    return ok;
}

The problem is that ok == NO. I.e. migration fails and I have no idea where to look for hints or explanations. The error is pretty meaningless except for its userInfo dictionary. Moreover the error is swallowed on the way up to the user where it appears as a generic "cannot open" message.

Now what I can't understand is why both source and destination models have the same versionIdentifiers. I guess this would also explain why the mapping model is not found.

Best,
Pierre


On Nov 1, 2007, at 3:23 AM, mmalc crawford wrote:


On Oct 31, 2007, at 4:00 PM, Pierre Bernard wrote:

Does NSPersistentDocument handle versioning issues or do I need to hook into document loading to call the migration manager myself?
What is the recommended approach for using the migration manager within the NSDocument architecture?


It's just as described here <http://developer.apple.com/documentation/Cocoa/Conceptual/CoreDataVersioning/Articles/vmInitiating.html >.

mmalc


--- Pierre Bernard http://www.bernard-web.com/pierre http://www.houdah.com



_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please 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


  • Follow-Ups:
    • Re: [Leopard] Core Data model versioning vs. NSPersistentDocument
      • From: Pierre Bernard <email@hidden>
  • Prev by Date: Re: exec() with pmset
  • Next by Date: Re: @properties and Information Hiding
  • Previous by thread: Re: Data Rich email like iPhoto/Aperture?
  • Next by thread: Re: [Leopard] Core Data model versioning vs. NSPersistentDocument
  • Index(es):
    • Date
    • Thread