iphone - obj-c concatenate int issue -


I'm new to obj-c and I'm trying a simple IBAction code where clicking a button once But its label This image works well with background and static strings, but when it crashes on it:

  int i = (arc4random ()% 90); NSString * Lab = [NSString stringWithFormat: @ "% d", i]; [Sender set text: lab];   

Why? Ty in advance

Edit: This is the complete method

  - (IBAction) toggle UI button icon: (ID) sender {NSString * img = @ "bulldog-cute -tom-bancroft.jpg "; NSString * imgSel = @ "kitten-cute-tom-bancroft.jpg"; UIImage * unselectedImage = [UIImage imageNamed: img]; UIImage * Selected Image = [UIImage imageNamed: imgSel]; If ([sender is selected]) {[sender setbackgaged image: state for unselected image: UIControllstat normal]; [Sender set selected: no]; } And {[sender setbackgaged image: state for selected image: UIControlState selected); [Sender set selected: yes]; } Int i = (arc4random ()% 90); NSString * Lab = [NSString stringWithFormat: @ "% d", i]; [Sender Situation: State for Laboratory: UCentolstadt Normal]; } 

This is not a random int or int2str conversion, the way you type your button text Use it and it should work:

  [Sender's Situation: State for Laboratory: UCentralStateAnimal];   

(It is if the sender is actually a UIButton)

Edit:

  UIButton * button = (UIButton * ) Sender; From the sender, UIButton * (or any other specific class that you want to answer the method) is advised, along with it to ensure that you have the right class methods. Work together.  P>  

Comments