• 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
Help with Undo and MVC
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Help with Undo and MVC


  • Subject: Help with Undo and MVC
  • From: Stephen Magyari <email@hidden>
  • Date: Sun, 02 Nov 2003 23:31:22 -0800

I've exhausted every brain cell I have left (both of 'em) trying to get
Undo/Redo support to work in my Obj-C Doc-based Cocoa app, and I'm stuck.
I've searched the archives, read this article
(www.ex-cinder.com/downloads/undo-article.rtf), read through the docs, and
perused the included Example code (Sketch, TextEdit, and SimpleComboBox
primarily) and after several attempts & variations, I have myself thoroughly
confused -- it has to be something so obvious that I'm clearly missing
it....

Following the info from the archives & the article, I have the Undo/Redo
support at the model level, while my document is acting as the controller.

As such, I have a model "Book" (NSObject subclass) with (for example):

- (void)setBookTitle:(NSString *)title;
{
[[undoManager prepareWithInvocationTarget:self]
setBookTitle:newBookTitle];
[newBookTitle release];
newBookTitle = title;
}

I think the code above is correct (based on the examples I've seen) but my
app won't compile (under Xcode), stating, "error: 'undoManager' undeclared
(first use in this function....)"

I have the following in my document's implementation:

- (NSUndoManager *)undoManager {
return [self undoManager];
}

I've tried importing my document's .h file into the model's implementation,
forward-declaring my document's class in the model's .h file, etc... but
nothing resolves the error, so I'm stumped on how to get my model to
recognize that the undoManager does indeed exist for the document.

Can someone please help me with the above by pointing out what I'm missing
or doing wrong, or an alternative way of implementing Undo/Redo?

Regards,
Stephen
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: Help with Undo and MVC
      • From: Laurent Daudelin <email@hidden>
    • Re: Help with Undo and MVC
      • From: Drew McCormack <email@hidden>
  • Prev by Date: Re: not performing selector...
  • Next by Date: Re: Distributed Objects overkill?
  • Previous by thread: Re: not performing selector...
  • Next by thread: Re: Help with Undo and MVC
  • Index(es):
    • Date
    • Thread