Re: "How do I get undo/redo for free in my non-document-architecture-based app?"
Re: "How do I get undo/redo for free in my non-document-architecture-based app?"
- Subject: Re: "How do I get undo/redo for free in my non-document-architecture-based app?"
- From: mmalc crawford <email@hidden>
- Date: Mon, 18 Sep 2006 11:39:30 -0700
On Sep 18, 2006, at 10:17 AM, Arthur C. wrote:
In the Core Data FAQ (Core Data Programming Guide 2006-09-05 page
143) there is an item called
"How do I get undo/redo for free in my non-document-architecture-
based app?"
It says I can get the undo manager from the managed-object context:
"If your window delegate has an accessor method for the managed
object context (as is the case if you use the Core Data Application
template), your implementation of windowWillReturnUndoManager:
might be as follows.
-(NSUndoManager *) windowWillReturnUndoManager:(NSWindow *) sender
{
return [[self managedObjectContext] undoManager];
} "
The question is, where do I have to put this code? Where can I find
the 'window delegate'? Is it the 'projectname_Appdelegate.m' file?
To give what is necessarily a circular answer, the window's delegate
is whatever object you have set up as the window's delegate. This is
typically set up in Interface Builder, and in the Core Data
Application template is set up to be the app delegate.
And, isn't it true that the managed object context can be retrieved
anywhere using something like
NSManagedObjectContext * managedObjectContext = [[NSApp delegate]
managedObjectContext];
*If* you're using the Core Data Application template application
*and* you haven't modified it, then yes. But there are of course
other application architectures...
As a general point, however, if you do not understand this subject I
would recommend not using Core Data until you do. Core Data is not
an entry-level technology and builds upon the technologies and
patterns that are present in Cocoa -- you should gain a deeper
understanding of these first.
mmalc
_______________________________________________
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