On Sep 30, 2009, at 9:47 PM, Michael Ash wrote:
On Wed, Sep 30, 2009 at 9:39 PM, Adam R. Maxwell <[email protected]> wrote:On Sep 30, 2009, at 7:15 PM, Graham Cox wrote:On 01/10/2009, at 12:06 PM, Adam R. Maxwell wrote:That should bring you to a helpful discussion titled "Advice for Overriders of Methods that Follow the delegate:didSomethingSelector:contextInfo: Pattern."Wow. I thought it was byzantine even before I read this ;-)Ah, but once you've seen it, you can't forget it :). The most interesting bits of documentation are almost invariably the release notes (but they'realso the hardest to find).NSInvocation is crazy overkill for this. It's extremely difficult to write, and as a bonus it'll be about two orders of magnitude slower than a regular message send too. A much simpler way is to do it like this (code not tested, etc.): void (*method)(NSDocumentController *, BOOL, void *) = (void*)[delegate methodForSelector: didAllCloseSelector]; method(delegate, didAllCloseSelector, self, YES, contextInfo); I really don't know why Apple recommends such a complicated way.
I don't find NSInvocation any more complicated than declaring a function pointer, personally, although it is verbose to the point of tediousness. I've used IMP caching for performance, but in this case I believe that "two orders of magnitude slower" for a single message send isn't going to matter at all when closing a document. Go with whatever way looks easiest or most readable, and optimize later.
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________ 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]
