Re: Compiler Warning City
Re: Compiler Warning City
- Subject: Re: Compiler Warning City
- From: Greg Titus <email@hidden>
- Date: Thu, 24 Oct 2002 14:40:30 -0700
The reason why you are getting these warnings isn't because you are
using type "id", it is because the compiler can't find any
implementation at all of the method selector "whatever:" so it can't
guarantee that it is creating correct code for it. (For instance, if
-whatever: actually returns a double instead of an id, the generated
code here will be looking in the wrong register.)
The way to get rid of these warnings is to declare the -whatever:
method anywhere that the file you are compiling imports. This can be in
a protocol or as an unimplemented category on NSObject (a so called
informal protocol). If you look at the bottom of NSTableView.h in
AppKit, for instance, you will see a couple of informal protocols for
the data source methods. These declarations both
(a) Tell the compiler what is intended when the NSTableView code calls
them on its data source (which is declared "id", you'll notice), and
(b) Helps document the methods that this class uses, so coders writing
NSTableView data sources can do the right thing.
Hope this helps,
-Greg
On Thursday, October 24, 2002, at 02:20 PM, G Douglas Davidson wrote:
Is there any way to use type "id" and not get two compiler warnings
per usage?
1. warning: cannot find method
2. warning: return type for "whatever:" defaults to id
There are some times where I don't want or can't easily use static
typing, and it would be really nice if the compiler could say "Hey,
its type 'id', that means he does not want warnings about methods
(which would be impossible anyway) and warnings about return types
(which would also be impossible.)" Ideally I'd like the compiler to
check on the static stuff and not on the type "id" stuff.
Is this possible?
--
G. Douglas Davidson | CityNet, Inc.
email@hidden | Pittsburgh, PA
voice: 412.481.5406 | fax: 412.431.1315
_______________________________________________
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.
_______________________________________________
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.