• 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 and Document Packages
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Core Data and Document Packages


  • Subject: Re: Core Data and Document Packages
  • From: sergio <email@hidden>
  • Date: Thu, 12 Jul 2007 17:14:59 +0200

Hi Tim,

> Very nice, I wasnt aware of NSDocumentController. I also had to add  
> an init method;
>
>    def init
>      super_init()
>    end

this makes sense, and actually I defined one in the first place, but
all kept working also after removing it...

> earlier in the thread and found a few problems with it; namely you  
> cant re-open documents once they have been saved (the saving works  

does this possibly happen when you choose a document from the recent
documents menu? try to open via the open command, it works perfectly for
me...

> perfectly however), and you are calling a method dataFilePath() for  
> which there is no definition. I am guessing you mean to actually  
> access the data file with that method, so is that the same function  
> as packagePath() ?

you are right, I messed things a little bit when polishing the code for
posting... :-( now I have renamed this method into
dataStoreURLFromPackageURL to make it more meaningful -- and it's
exactly what you mention.

> If your working with a core data based document you will need to use  
> the configurePersistentStoreCoordinatorForURL_ofType() method wont  
> you? Apart from it will somehow need to pass the data file within the  
> package rather than the package url itself?

as far as I understand, this is accomplished by the init trick. since I
am initializing the document with the url to the data file within the
package, then configurePersistentStoreCoordinatorForURL_ofType will
receive the url just right. when you create a new document, the flow is
a bit different and the trick is done when calling super_writeToURL with
the modified url.

I think you override configurePersistentStoreCoordinatorForURL_ofType
when you want to take the approach preferred by Seth -- which could even
provide a cleaner implementation, but I could not get anywhere that way.

If you have more troubles, if you like, you can send me your code, so
that I take a look at it... in my case, I can create a new document and
save it as many times as I need (there used to be problems with the
second save), open a document and edit/save it at will, revert a
document, and save as. Thanks to a reader of my blog I also discovered
that this solution is resilient to moving the package around while it is
being edited -- and this actually surprised me a lot... now, it would be
even more surprising discovering that it works only on my system (which
could perfectly be the case)... :-)

best
sergio

>
> Cheers
>
> Tim Perrett

--
GMX FreeMail: 1 GB Postfach, 5 E-Mail-Adressen, 10 Free SMS.
Alle Infos und kostenlose Anmeldung: http://www.gmx.net/de/go/freemail
_______________________________________________

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: Core Data and Document Packages
      • From: Tim Perrett <email@hidden>
  • Prev by Date: Re: NSNumberFormattter not working
  • Next by Date: Re: Cross-platform toolkit with a Cocoa backend
  • Previous by thread: Re: Core Data and Document Packages
  • Next by thread: Re: Core Data and Document Packages
  • Index(es):
    • Date
    • Thread