• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Casting anonymous Objects leads to different values on getter functions (while getting no warnings at compile time)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Casting anonymous Objects leads to different values on getter functions (while getting no warnings at compile time)
      • From: Martin Wilz <email@hidden>
References: 
 >Casting anonymous Objects leads to different values on getter functions (while getting no warnings at compile time) (From: Martin Wilz <email@hidden>)

  • Prev by Date: RE : newbie: adding nibs: i'm stuck
  • Next by Date: Re: OK to Use C++ Shorthand Constructs in a Cocoa Project?
  • Previous by thread: Re: Casting anonymous Objects leads to different values on getter functions (while getting no warnings at compile time)
  • Next by thread: Re: Casting anonymous Objects leads to different values on getter functions (while getting no warnings at compile time)
  • Index(es):
    • Date
    • Thread