• 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: CoreData Migration Problems
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: CoreData Migration Problems


  • Subject: Re: CoreData Migration Problems
  • From: Quincey Morris <email@hidden>
  • Date: Tue, 8 Feb 2011 12:51:10 -0800

On Feb 8, 2011, at 12:08, Gordon Apple wrote:

>    persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc]
> initWithManagedObjectModel: self.managedObjectModel];
>
>    NSError *error = nil;
>    NSPersistentStore* store =
>    [persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType
>                                             configuration:nil
>                                                       URL:storeUrl
>                                                   options:options
>                                                     error:&error];
>    if(store != nil)
>        return persistentStoreCoordinator;    //    Normal exit.
>
> // Error handling...
>    return nil;
> }

It seems to me there's only two ways this code can return nil -- one is if 'initWithManagedObjectModel:' returns nil (which you don't check for, but will result in store being nil down the line), and the other is if 'addPersistentStoreWithType:...' detects an error.

So you first need to know which of the two actually happens. If adding the persistent store returns an error, what is the error?

Also, did you check the log for any error messages?

> I am confused about some things going on behind-the scenes.  The project
> folder contains only the xcdatamodeld file (the compiled version), not the
> original xcdatamodel shown in the project listing.  Also, for the main
> entity, somewhere along the way, the project folder has picked up a folder
> labled "Model-1.moved-aside", which does not show up in the project window.
> Is this something needed in the migration?  I'm about at my wit's end with
> this thing.

This doesn't seem wrong, necessarily. 'xcdatamodeld' is the extension for a *package* folder that contains the 'xcdatamodel' files when you have multiple model versions -- as you now do. The 'moved-aside' item sounds like a consequence of the problems you reported earlier in getting a copy of your project to refer to the correct model files -- I wouldn't necessarily worry any further about it.


P.S. It's OT, but initializing 'error' to nil before passing it to an error-returning method is both a waste of time and semantically incorrect -- it's an *output only* parameter to the method. OTOH, setting it to nil isn't inherently harmful. :)

_______________________________________________

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:
    • Initializing NSError **, again Re: CoreData Migration Problems
      • From: Fritz Anderson <email@hidden>
    • Re: CoreData Migration Problems
      • From: Gordon Apple <email@hidden>
References: 
 >CoreData Migration Problems (From: Gordon Apple <email@hidden>)

  • Prev by Date: CoreData Migration Problems
  • Next by Date: Re: CoreData Migration Problems
  • Previous by thread: CoreData Migration Problems
  • Next by thread: Re: CoreData Migration Problems
  • Index(es):
    • Date
    • Thread