On Feb 11, 2011, at 12:20 PM, Joanna Carter wrote: > >> Consider NSInvocation... m. > > Hmmm, nice! > > My only objection to using it in the circumstances I have is that it is a lot > more code to setup
But consider NSUndoManager. What its +prepareWithInvocationTarget:+ does is almost exactly what you describe: you give it a target and send it a method call, a method call that NSUndoManager itself cannot respond to. Instead of complaining, it freeze-dries that method call and its parameters and the target into an NSInvocation and puts it on the Undo stack. (This is the only place where it differs from what you said; you said a "dictionary".) When you later say "undo" to the NSUndoManager, it pops that NSInvocation off the stack, un-freeze-dries it, and calls it. So NSUndoManager has a completely general way of freeze-drying *any* method call into an NSInvocation, on the spot! It isn't doing this by magic; it's using Objective-C's wonderful runtime. And so can you. m. -- matt neuburg, phd = [email protected], http://www.tidbits.com/matt/ pantes anthropoi tou eidenai oregontai phusei Among the 2007 MacTech Top 25, http://tinyurl.com/2rh4pf AppleScript: the Definitive Guide, 2nd edition http://www.tidbits.com/matt/default.html#applescriptthings Take Control of Exploring & Customizing Snow Leopard http://tinyurl.com/kufyy8 RubyFrontier! http://www.apeth.com/RubyFrontierDocs/default.html TidBITS, Mac news and reviews since 1990, http://www.tidbits.com _______________________________________________ Cocoa-dev mailing list ([email protected]) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [email protected]
