• 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: Concerns about changing NSManagedObjectContext
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

re: Concerns about changing NSManagedObjectContext


  • Subject: re: Concerns about changing NSManagedObjectContext
  • From: Ben Trumbull <email@hidden>
  • Date: Sat, 16 Jun 2007 14:42:46 -0700

Jim,

There are only three differences between a Core Data document based application, and the non-document style.

First, the document based application uses a subclass of NSDocument called NSPersistentDocument

Second, the templates in Xcode are slightly different to make things easier for integration with a focus on that app style. Nothing you couldn't copy and paste into your own app.

Finally, the standard document templates has a separate Core Data stack (store, coordinator, context) for each document. The non- document style template creates a single shared Core Data stack.

That's it. From Core Data's perspective, there isn't any difference between documents using databases and any other kind of app using a database. The bulk of the differences are about making it easy to leverage Cocoa features provided by NSDocument and friends.

As for your backup/restore plan, you could also use Core Data's migratePersistentStore: method on the NSPersistentStoreCoordinator. This won't be as fast as a file system copy, but the newly created store will have a separate identity (metadata && UUID) so both files can be opened at once. If you duplicate a store at the file level, we'll only let you add one of them to any specific coordinator.

1) discard changes in the current store and throw away the context and the store coordinator.

A couple points here. First, persistent stores don't have changes. All the changes are tracked by the NSManagedObjectContext. You can simply call -reset on the context, and removePersistentStore: on the coordinator, and then add the new store.


You'll need to discard any managed objects you have and fetch anew from the newly added store.

However, it might be nearly as much work to simply move your app to use documents. For each document your customer wants opened, create a new coordinator, and a new context. From there, it's all about nibs and bindings ...

- Ben

_______________________________________________

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


  • Follow-Ups:
    • Re: Concerns about changing NSManagedObjectContext
      • From: "Jim Thomason" <email@hidden>
  • Prev by Date: re:Core Data File Sharing via an AFP Alias
  • Next by Date: Re: Resolution-independent toolbar icons
  • Previous by thread: Concerns about changing NSManagedObjectContext
  • Next by thread: Re: Concerns about changing NSManagedObjectContext
  • Index(es):
    • Date
    • Thread