Re: Implementing delegate categories for subclasses

Christiaan Hofman <[email protected]>
Newsgroups gmane.comp.macosx.devel
Message-ID <[email protected]>
On Sep 9, 2009, at 20:40, Kyle Sluder wrote:

> On Wed, Sep 9, 2009 at 11:31 AM, Christiaan  
> Hofman<[email protected]> wrote:
>> And anyway, my main question is not solved by this insight, even if  
>> I only
>> want to support 10.5 and 10.6. I still get warnings either with the  
>> 10.5 or
>> the 10.6 SDK.
>
> I don't see why:
>
> @protocol MyTableViewDelegate
> #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
> <NSTableViewDelegate>
> #endif

>
> -(void)myTableViewRequiredDelegateMethod:(MyTableView *)aTableView;
>
> @optional
> -(void)myTableViewOptionalDelegateMethod:(MyTableView *)aTableView;
>
> @end
>
> --Kyle Sluder

That does not solve the problem with the type of the delegate. In  
fact, that does not solve any of my problems. The problem is not that  
NSTableViewDelegate is not defined, because that must be defined  
anyway (as the release notes suggest). The problem is that the type of  
the delegate is different in the 10.5 and 10.6 SDKs: in one it's id,  
while in the other it's id<NSTableViewDelegate>.

Of course I can add loads of #if, but that really makes the code a mess.

Also, can I target 10.4 when I use @optional? I do need that for now.  
The docs say that if I use an Obj-C 2.0 feature I can't.

Remember, my main question was: what is the preferred way to do this?

Christiaan
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.