• 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: save to multiple files?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Core Data: save to multiple files?


  • Subject: Re: Core Data: save to multiple files?
  • From: Chris Hanson <email@hidden>
  • Date: Sun, 1 Apr 2007 13:01:55 -0700

On Mar 31, 2007, at 8:20 AM, Patrick Crosby wrote:

I have a document-based core data app with something like:

Document -> has many -> Page -> has many -> Block

(one Document object which has many Page objects.  Each Page object
has many Block objects.)

It all works fine and saves the document to one big file.

Say for some perverse reason I want to save each Page object (and the
many Block objects that belong to it) to separate files, one file per
Page.  Is this possible?

Yes. You need to do three things:

(1) Break your Document <--->> Page relationship pair, and represent it some other way because Core Data does not support cross-store relationships. It might be useful to represent it as a transient relationship pair instead, and use a some other identifier in an attribute on Document and Page to implement your own key.

(2) Add multiple persistent stores to your NSPersistentStoreCoordinator, one to represent each page. You can do this at any point prior to save.

(3) Use -[NSManagedObjectContext assignObject:toPersistentStore:] to associate specific managed objects with specific persistent stores. You can also do this at any point prior to save.

I believe this is covered in the CoreRecipes sample code on the Apple Developer Connection web site.

  -- Chris

_______________________________________________

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


  • Prev by Date: Re: Core Data - SQLite persistent store file size optimization
  • Next by Date: Re: Core Data - SQLite persistent store file size optimization
  • Previous by thread: Re: EXC_BAD_ACCESS when calling third party library function
  • Next by thread: Re: PDFView won't display the first time?
  • Index(es):
    • Date
    • Thread