• 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: NSUndoManager setActionName: oddity
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSUndoManager setActionName: oddity


  • Subject: Re: NSUndoManager setActionName: oddity
  • From: Conrad Shultz <email@hidden>
  • Date: Mon, 02 Jul 2012 10:26:39 -0700

Thanks Kyle.

As I mentioned the actual action opening the undo group is in the -insertObject:in: method in the model, which does work. My very first thought was an ordering issue so I tried inverting the order of method calling on the wrapper to no avail, but as Michael pointed out this might have been fruitless anyway.

I'll take a look at GCUndoManager. I'd heard of it being used in the context of Core Data, but maybe I should consider it here too. (I hate to introduce third-party dependencies unless absolutely necessary.)

I could set the action name in the model too, but that feels icky. (Do you set the action name or just register undo operations in the model? I don't see why action names would be needed for scripting, but then again I don't really know AppleScript.)

(Sent from my iPhone.)

--
Conrad Shultz

On Jul 2, 2012, at 8:25, Kyle Sluder <email@hidden> wrote:

> On Jul 2, 2012, at 2:35 AM, Conrad Shultz <email@hidden> wrote:
>
>> - (void)addRecord:(id)sender
>> {
>>   if (! [[self undoManager] isUndoing]) {
>>       [[self undoManager] setActionName:NSLocalizedString(@"Add Record", nil)];
>>   }
>>   [[self arrayController] add:sender];
>> }
>
> IIRC, you need to put the call to -setActionName: *after* the action that opens the undo group. Which I don't see you doing here, but I suppose you're relying on it happening as a side effect of whatever the array controller does?
>
> This is because NSUndoManager is a very old class with a very weird internal data structure that can't attach an action name without an object at the top of its stack. You might investigate using Graham Cox's GCUndoManager.
>
> FWIW, we put all our undo actions in the model because of AppleScript, but that makes our model single-threaded.
>
> --Kyle Sluder

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please 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: NSUndoManager setActionName: oddity
      • From: Graham Cox <email@hidden>
    • Re: NSUndoManager setActionName: oddity
      • From: Kyle Sluder <email@hidden>
References: 
 >NSUndoManager setActionName: oddity (From: Conrad Shultz <email@hidden>)
 >Re: NSUndoManager setActionName: oddity (From: Kyle Sluder <email@hidden>)

  • Prev by Date: Re: Equation style display
  • Next by Date: NSDocument last document loading
  • Previous by thread: Re: NSUndoManager setActionName: oddity
  • Next by thread: Re: NSUndoManager setActionName: oddity
  • Index(es):
    • Date
    • Thread