Hi Matt > 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.
I would totally agree that it is a phenomenally powerful concept, giving just the kind of functionality I was originally looking for, as a replacement for method pointers. I will be using it as soon as I find a need that warrants it. But, in my current code, I realise now that it was a lot easier to simply take the protocol/method approach. In addition to pointing me to NSInvocation, you have lifted the mist from my eyes as to how NSUndoManager can work. Once again, many thanks. Joanna -- Joanna Carter Carter Consulting _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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 arch...@mail-archive.com