Re: NSDocumentController didCloseAllSelector
Re: NSDocumentController didCloseAllSelector
- Subject: Re: NSDocumentController didCloseAllSelector
- From: Michael Ash <email@hidden>
- Date: Wed, 30 Sep 2009 23:47:54 -0500
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.
(You can also call objc_msgSend() to do it all in one shot, but this
saves you from having to worry about whether you need to use a special
function for float returns, etc. You *do* have to worry about struct
returns, though, and you should not use this technique in that case.)
Mike
_______________________________________________
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