• 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: Sending the "value" message to an object typed "id"
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Sending the "value" message to an object typed "id"


  • Subject: Re: Sending the "value" message to an object typed "id"
  • From: Jens Alfke <email@hidden>
  • Date: Mon, 7 Sep 2009 10:13:30 -0700


On Sep 7, 2009, at 5:11 AM, Graham Cox wrote:

I suspect what's occurring is that -value is defined in multiple classes having different return types: maybe float in one case and id in another, say. The compiler can't disambiguate a method based on return type alone so compiles based solely on the first one it encounters, which to all intents and purposes may as well be random. It's a dirty little secret of Obj-C (or at least the current compilers) and is a very real source of bugs (and sometimes quite dangerous ones at that).

BTW, Paulo, this situation should have generated a compiler warning saying that it can't tell which version of the 'value' message it should use here. Whenever you get a warning like that, you should cast the receiver to the appropriate class.


(This is yet another reason I recommend always enabling "treat warnings as errors" when building Obj-C code.)

—Jens_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Sending the "value" message to an object typed "id" (From: "Paulo F. Andrade" <email@hidden>)
 >Re: Sending the "value" message to an object typed "id" (From: Graham Cox <email@hidden>)

  • Prev by Date: Re: mouseDown Event Position Accuracy (was: NSString drawAtPoint and vertical font alignment)
  • Next by Date: Re: How to play the movie(.mov) looped using QTMovie ?
  • Previous by thread: Re: Sending the "value" message to an object typed "id"
  • Next by thread: Weird malloc error when dealing with lots of NSImage objects
  • Index(es):
    • Date
    • Thread