• 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
NSUndoManager in non-NSDocument Cocoa Applications: unable to change 'Undo' menu item name.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSUndoManager in non-NSDocument Cocoa Applications: unable to change 'Undo' menu item name.


  • Subject: NSUndoManager in non-NSDocument Cocoa Applications: unable to change 'Undo' menu item name.
  • From: "Frederick C. Lee" <email@hidden>
  • Date: Wed, 16 Jun 2004 14:26:21 -0700

re: unable to change the 'Undo' Menu Item name.

Greetings:
I've studied examples of using NSUndoManager within NSDocument
projects, where 'undoManager' is integral to NSDocument & offspring.

However, I'm not using NSDocument in my appl so I have to create an
'undoManager' instance within the following paradigm:

GUI <--> MyController <--> CountryModel {controller:
source of NSUndoManager; Model: setting & registering an Undo instance}


I've created a NSUndoManager instance in 'MyController' via:
undoManger = [[NSUndoManager alloc] init];
// MyController.m

I pass it to a new CountryModel object (following the NSDocument
example) via:

- (id)initWithUndoManager:(NSUndoManager *)newUndoManager //
CountryModel.m
{
self = [self init];
[self setUndoManager:newUndoManager];

return self;
}

This essentially restocks the CountryModel's version of undoManager per
each CountryModel creation:

- (void)setUndoManager:(NSUndoManager *)newUndoManager
{
[newUndoManager retain];
[undoManager release];
undoManager = newUndoManager;
}

=====

A few CountryModel's Setters have the NSUndoManager's 'setActionName' &
registration statements:

....
- (void) setCurrencyName: (NSString *)theName {
if (currencyName) {
[theName retain];
NSLog(@"{CountryModel} setCurrencyName.");
[undoManager setActionName:@"Currency Name"];
[undoManager registerUndoWithTarget:self
selector:@selector(setCurrencyName:)
object:currencyName];
}
[currencyName release];
currencyName = theName;
}
....

PROBLEM: I don't see "Currency Name" associated with the 'Undo' (e.g.,
"Undo Currency Name") Edit-Menu item. I've reversed-engineered
NSDocument examples to the creation of the 'undoManager' instance
variable.

Reverse-Engineering the Doc example:
I overrid the NSDocument's undoManager in the document example using
[[NSUndoManager alloc]init] and lost the 'setActionName' effect.

So there's probably a correlation with my problem.

Somehow, merely doing a NSUndoManager initiation within the controller
isn't enough.
I tried locally-defining undoManager (w/in CountryModel):
undoManager = [[NSUndoManager alloc]init]; // locally defined.
...
<setter method>
[undoManager setActionName:@"TEST"];
<close setter method>

...with no effect.

Question: What am I missing?

Thanks in advance!

Regards,
Ric.
_______________________________________________
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: NSUndoManager in non-NSDocument Cocoa Applications: unable to change 'Undo' menu item name.
      • From: James DiPalma <email@hidden>
    • Re: NSUndoManager in non-NSDocument Cocoa Applications: unable to change 'Undo' menu item name.
      • From: Nick Zitzmann <email@hidden>
  • Prev by Date: Re: Online help question
  • Next by Date: Re: Online help question
  • Previous by thread: Strange application behavior with distributed notification center
  • Next by thread: Re: NSUndoManager in non-NSDocument Cocoa Applications: unable to change 'Undo' menu item name.
  • Index(es):
    • Date
    • Thread