Re: Categories and Compiler Warnings
Re: Categories and Compiler Warnings
- Subject: Re: Categories and Compiler Warnings
- From: matt neuburg <email@hidden>
- Date: Fri, 28 May 2004 07:15:37 -0700
On Thu, 27 May 2004 23:29:32 -0700, Daniel Todd Currie <email@hidden>
said:
>
I have added a private category of MyClass to MyClass's .m file, like
>
so:
>
>
> @implementation MyClass
>
> [...]
>
> @end
>
>
>
> @interface MyClass (Private)
>
> - (void)myPrivateMethod;
>
> @end
>
>
>
> @implementation MyClass (Private)
>
> - (void) myPrivateMethod {
>
> [...]
>
> }
>
> @end
>
>
The problem is that whenever I call myPrivateMethod from the
>
public/primary MyClass implementation, I get one of those annoying "may
>
not respond to" compiler warnings. What is the point of even having an
>
interface if I still get warnings?
The problem is that the implementations are backwards. If it's all in one
file like this, make either the implementation for MyClass (Private) or the
interface for MyClass (Private) precede the implementation for MyClass
(Public). You do not need the interface for MyClass (Private) at all in the
former case, by the way.
This is for exactly the same reason that an undeclared method must precede a
call to that method in the same file. A file has a linear order so things
must appear in that order. Objective-C is C. m.
--
matt neuburg, phd = email@hidden,
http://www.tidbits.com/matt/
pantes anthropoi tou eidenai oregontai phusei
AppleScript: the Definitive Guide! NOW SHIPPING...! (Finally.)
http://www.amazon.com/exec/obidos/ASIN/0596005571/somethingsbymatt
Subscribe to TidBITS! It's free and smart.
http://www.tidbits.com/
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.