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

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


  • Subject: Sending the "value" message to an object typed "id"
  • From: "Paulo F. Andrade" <email@hidden>
  • Date: Mon, 7 Sep 2009 12:36:13 +0100

I was explaining the difference between typing objects with id instead of UISlider * (in this case) to a friend and came across this weird behaviour.

Consider the folowing method that is called when chaing the value of a UISlider:

===
- (IBAction)changeValue:(id)sender
{
	[textLabel setText:[NSString stringWithFormat:@"%f", [sender value]]];
}
===

[sender value] in this case returns the actual slider object...

If we cast sender to UISlider everything works as expected.

My first thought was that this behaviour may have to do with UISlider's -value method returning a float instead of an object.
However if I use [sender maximumValue] which also retuns a float it works..


So what's the deal with the method name "value" and ObjC runtime?


Paulo F. Andrade



_______________________________________________

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


  • Follow-Ups:
    • Re: Sending the "value" message to an object typed "id"
      • From: Graham Cox <email@hidden>
  • Prev by Date: Re: Crash on SL in com.apple.DesktopServices after using NSOpenPanel
  • Next by Date: Weird malloc error when dealing with lots of NSImage objects
  • Previous by thread: Re: Problem with LSSharedFileListInsertItemURL() usage. (API in LaunchServices/LSSharedFileList.h)
  • Next by thread: Re: Sending the "value" message to an object typed "id"
  • Index(es):
    • Date
    • Thread