Re: No warnings of missing prototypes during builds
Re: No warnings of missing prototypes during builds
- Subject: Re: No warnings of missing prototypes during builds
- From: Public Look <email@hidden>
- Date: Mon, 17 Nov 2003 23:17:51 -0500
There is no requirement that methods implemented in a class
@implementation file have any corresponding declaration in a class
@interface. If you attempt to use a method (selector) that the
compiler has never seen before, you may get a warning because the
compiler does not know the return type and argument types. If you
declare methods in a @interface and don't implement them in the
corresponding @implementation, you may get a warning. As far as I
know, there has never been a warning for implementing a method that was
not declared. In Objective-C, it not _necessary_ to declare any
methods at all in an @interface. If you are careful about the order in
which methods are implemented in an @implementation, you can usually
avoid warnings when compiling even if none of the implemented methods
were declared in any interface.
To avoid your problem, I usually do two things. I copy and paste
method names so there is no chance of a typo or misspelling, and I
declare all methods (even private ones) in an @interface somewhere.
That way, I get a warning if a declared method is not implemented which
usually means I misspelled either the declaration or the
implementation.
Hint: You can declare private methods within a category interface
inside a .m file. That satisfies the compiler and does not advertise
the existence of the methods to anyone who looks at a .h file.
On Nov 17, 2003, at 10:50 PM, Bruce Montegani wrote:
I just spent about half an hour debugging an application because I had
misspelled an implementation override of 'makeWindowContollers' method
in MyDocument .
I had implemented the method 'makeWindowsControllers' by accident.
Isn't the Build process in XCode supposed to show me missing function
declarations for my implemented methods. I know this worked in Project
Builder.
Any help would be appreciated.
_______________________________________________
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.