• 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: How to make Redo work with a custom group
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to make Redo work with a custom group


  • Subject: Re: How to make Redo work with a custom group
  • From: David Spooner <email@hidden>
  • Date: Mon, 29 Oct 2007 14:46:40 -0600


On 29-Oct-07, at 1:54 PM, Paul Bruneau wrote:

On Oct 29, 2007, at 3:25 PM, David Spooner wrote:

I found the following method useful for the many situations in which I wanted undo for setting object attributes...

@implementation NSObject(...)
- (void) setValue:(id)value forKeyPath:(NSString *)path undo: (NSUndoManager *)undo
{
if (undo != nil)
[[undo prepareWithInvocationTarget:self] setValue:[self valueForKeyPath:path] forKeyPath:path undo:undo];
[self setValue:value forKeyPath:path];
}
@end

That is neat. I must admit a certain fuzziness for setValue: forKeyPath: that I hope to clear up over time. Is your undo != nil test just habit from another language or does it serve a real purpose? If undo is nil, no harm is caused by sending it a message, no?



It's just an optimization to avoid calling -valueForKeyPath: unnecessarily.


dave

_______________________________________________

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


References: 
 >How to make Redo work with a custom group (From: Paul Bruneau <email@hidden>)
 >Re: How to make Redo work with a custom group (From: David Spooner <email@hidden>)
 >Re: How to make Redo work with a custom group (From: Paul Bruneau <email@hidden>)
 >Re: How to make Redo work with a custom group (From: David Spooner <email@hidden>)
 >Re: How to make Redo work with a custom group (From: Paul Bruneau <email@hidden>)

  • Prev by Date: Re: Opening projects in upgraded OS
  • Next by Date: Re: Interface Builder 3.0 and applying window style: textured
  • Previous by thread: Re: How to make Redo work with a custom group
  • Next by thread: Trying to delete the first char of a string?
  • Index(es):
    • Date
    • Thread