Re: Casting anonymous Objects leads to different values on getter functions (while getting no warnings at compile time)
Re: Casting anonymous Objects leads to different values on getter functions (while getting no warnings at compile time)
- Subject: Re: Casting anonymous Objects leads to different values on getter functions (while getting no warnings at compile time)
- From: Hauke Klein <email@hidden>
- Date: Fri, 4 Nov 2005 15:16:40 +0100
On 04.11.2005, at 14:09, Martin Wilz wrote:
Somehow there seems to be confusion with other objects implementing
the width
method (e.g. NSTableColumn). The NSLog in my -width method - however -
shows that my method is called; it just does not return the correct
value.
I''ve seen conflicts like this before, but there were always warnings
while compiling, that led me to cause of the problem. Not in this case
(what I consider to be a bug in Xcode as I don't want to research
other objects using the same method names as I do nor do I want to use
Namespace for my method names to avoid collision...)
When compiling CastingTest.m, I get the warning
CastingTest.m: In function `-[CastingTest awakeFromNib]':
CastingTest.m:51: warning: multiple declarations for method `width'
/System/Library/Frameworks/AppKit.framework/Headers/NSTableColumn.h:42:
warning: using `-(float)width'
CastingTest.m:14: warning: also found `-(int)width'
Your method returns an integer, but the compiled code in -awakeFromNib:
thinks your -width method returns a float and this will not work. In
fact, when
replacing the second NSLog() with printf(), I also get a warning 'int
format,
double arg (arg 2)'.
When compiling '[[[config configurations] objectAtIndex:index] width]',
the
compiler does not know that [[config configurations]
objectAtIndex:index]
is a VideoQualityConfig, so it has to guess which of the both -width
signatures
will be used. IMHO, you are not supposed to use the same message name
with different type signatures.
Hauke Klein
_______________________________________________
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