Sending the "value" message to an object typed "id"
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