Re: XCode 2 upgrade problems... multiple methods with the samenameerrors
Re: XCode 2 upgrade problems... multiple methods with the samenameerrors
- Subject: Re: XCode 2 upgrade problems... multiple methods with the samenameerrors
- From: William Bumgarner <email@hidden>
- Date: Wed, 22 Mar 2006 08:44:24 -0800
On Mar 22, 2006, at 8:10 AM, Stephen C. Jensen wrote:
... why did I need to rename those functions? Both are defined
within an object ("employee"), so when I call [employee uniqueID],
why does the compiler complain? Why should there be any conflicts
in namespace between my object and [NSEvent uniqueID], or
[NSScriptObjectSpecifiers uniqueID]? I always thought that was one
of the benefits of object oriented programming... what am I
missing? Also, why the complaints now and not with XCode 1? I
suspect I have a setting that is different...
NSEvent:
- (unsigned long long)uniqueID;
NSScriptObjectSpecifiers:
- (id)uniqueID;
Presumably, your employee class has a different declaration for the
method.
More likely than not, you are referring to your employee as type
"id", the generic objective-c object pointer. As such, the compiler
doesn't know which of the uniqueID method signatures you are
intending to call. Objective-C does not do dispatch inferencing
based on the argument and return type of the methods (like other
languages), thus the compiler cannot infer what you mean either.
If you move to using specific type declarations, the compiler can be
more specific in its type checking. That is, use....
Employee *employee;
... instead of ....
id employee;
So, why the change? In between the old version of Xcode and the
modern version you are using now, the compiler was changed to emit
many more warnings about potentially problematic code. The warnings
are indicating that there are potential problems in your code. The
potential problems were always there, the tools just didn't
automatically detect them before.
Frankly, that NSEvent and NSScriptObjectSpecifiers declare methods
with identical selectors (names), but different type signatures, is
rather unfortunate and, even, borders upon a bug. There are only a
few methods for which a similar overlap exists.
b.bum
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden