• 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: Core Data versioning woes
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Core Data versioning woes


  • Subject: Re: Core Data versioning woes
  • From: Quincey Morris <email@hidden>
  • Date: Sun, 10 Aug 2008 20:08:56 -0700

On Aug 10, 2008, at 19:28, Graham Perks wrote:

On Aug 10, 2008, at 2:06 PM, Graham Perks wrote:
The document that's open post-migration is the "foo~" version

Is this a "feature" of migration? I tried the most basic migration app I could build. And when I try to save, it says "This document has been renamed to "test2~". While that's different from the message my real application gives, it's still completely bizarre. Why should a user care about the tilde filename at all?


Note that, at first, the document name in the title bar is the correct, non-tilde version, until you hit Save. Then the title bar name grows a tilde!!

I don't exactly remember the series of failed attempts I went through to get migration working, but this was possibly one of them. I think the problem you're running into is that migrating within the context of a NSPersistentDocument has pitfalls not present when migrating a non-document Core Data store, and its hard to tell from the documentation what works for documents and what does not. In particular, I don't think you can easily migrate the store after the NSPersistentDocument object has already been created.


The way I got it to work was to follow the strategy outlined in:

http://developer.apple.com/documentation/Cocoa/Conceptual/CoreData/Articles/cdImporting.html#/ /apple_ref/doc/uid/TP40003174-SW2

in the subsection titled "Document Based Example", but instead of implementing the data import loop I triggered the migration (for which there is useful sample code in the Core Data migration guide, but I expect you've written suitable code for this already). This basically performs the migration outside the context of a NSPersistentDocument, and just opens the result at the end. To make this work, I had to create my own temporary file for the result, manually rename out the old file with a "~" at the end of the migration, manually rename in the new file, and then open the new file. (The sample code shows how to subclass NSDocumentController to make this work.)

I may well have ended up reinventing some stuff that can be done automatically, but at least I got it working without sacrificing the last shreds of my sanity.


_______________________________________________

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


References: 
 >Core Data versioning woes (From: Graham Perks <email@hidden>)
 >Re: Core Data versioning woes (From: Graham Perks <email@hidden>)
 >Re: Core Data versioning woes (From: Graham Perks <email@hidden>)
 >Re: Core Data versioning woes (From: Graham Perks <email@hidden>)
 >Re: Core Data versioning woes (From: Graham Perks <email@hidden>)

  • Prev by Date: handling errors from NSNumberFormatter - how to determine exact nature of the error?
  • Next by Date: Why use NSObjectController?
  • Previous by thread: Re: Core Data versioning woes
  • Next by thread: Re: Core Data versioning woes
  • Index(es):
    • Date
    • Thread