Re: NEWBIE: Core Data Orientation questions
Re: NEWBIE: Core Data Orientation questions
- Subject: Re: NEWBIE: Core Data Orientation questions
- From: Chris Hanson <email@hidden>
- Date: Thu, 23 Jun 2005 00:24:59 -0700
On Jun 22, 2005, at 10:44 PM, Chris Hanson wrote:
How often or unusual would it be for an application to have more
than one Managed Object Context?
That depends on your application's needs. The combination of one
or more persistent stores, a persistent store coordinator, and one
or more managed object contexts is commonly referred to as a
"stack." If you have a document-based application where each
document is represented primarily by a single window, you'd
probably want one stack per document, with one persistent store and
one managed object context.
On the other hand, if you have an application that uses a single
persistent store but displays multiple windows, you might use
multiple managed object contexts on top of a single persistent
store coordinator and store, one per window. This will
Oops, sorry to trail off there.
In an application with a single persistent store but multiple
windows, using one managed object context per window will let you
isolate the changes you make in a window from changes in other windows.
For example, let's say you're writing an application to manage
recipes. To edit a recipe, you double-click its row in a table,
which opens a window containing the recipe's details. You add an
ingredient to recipe A, you change the name of recipe B, and then you
change the chef of recipe A. Then (with recipe A's window in front)
you choose "Undo" twice. What should happen?
If you're using a single managed object context, this will undo the
change to recipe A's chef, and then undo the change to recipe B's name.
If instead you're using multiple contexts with one context per window
(of course making sure that each context's undo manager is used for
the corresponding window) it will undo the change to recipe A's chef,
and then undo the change to recipe A's ingredients.
-- Chris
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden