Re: NSDocumentController didCloseAllSelector
Re: NSDocumentController didCloseAllSelector
- Subject: Re: NSDocumentController didCloseAllSelector
- From: "Adam R. Maxwell" <email@hidden>
- Date: Thu, 01 Oct 2009 07:56:50 -0700
On Sep 30, 2009, at 9:47 PM, Michael Ash wrote:
On Wed, Sep 30, 2009 at 9:39 PM, Adam R. Maxwell <email@hidden>
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're
also 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.
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
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