views:

74

answers:

1

-(void)clicketbutton{ UIButton *mybutton = [UIButton buttonWithType:UIButtonTypeCustom]; [mybutton setTitle:@"Click here" forState:UIControlStateNormal]; [mybutton addTarget:self action:@selector(displayvalue:)forControlEvents:UIControlEventTouchUpInside];

}

-(void)displayvalue:(id)sender{ UIButton *resultebutton= [UIButton buttonWithType:UIButtonTypeCustom];

resultebutton=sender;// pls clear here.. my question here , it it possible or not. if possible how ? NSLog(@" The buttontitile is %@ ", [resultebutton.Title] // here also. }

hi

in the above code i create a button and set title as ""Click here", when i pressed that button i want print "Clicke here" i mean its title. for that my code is here i mentioned. pls help me .. it is very very urgent....

thanks and regards

+1  A: 

iid is the sender, a pointer to the control that's calling your displayvalue method. You're casting the pointer to an integer, and printing the integer result. I'm not sure exactly what you're trying to accomplish, but the fastest way to get an integer from a button to the button's action method is to store it in the tag property.

If you go into a little more detail on what you're working on, I might be able to describe the best way to model that in a Cocoa app. Also, a tip-- be sure to fix any warnings in your code before trying to figure out why something's not working! That id -> int assignment would have made the compiler complain, for example.

Marc Charbonneau
hi arc charbonneau... Thankyou very much.. to response me..i mentioned my question very clearly.. pls help me.. it is very urget.thankyou very much onceagine
Raju