Reputation: 1083
when i am using string concatenation in method(like -(IBAction)buttonDigitPressed:(id)sender) it shows the blank.I am recall the method automatically terminate the app. what is the problem plz replay me.
NSString *str= @"";
-(IBAction)buttonDigitPressed:(id)sender{
int a = (int)[sender tag];
str= [str stringByAppendingFormat:@"%i",a];
label1.text= str;
}
this is the code. check the code send me the replay where i am doing the mistake.
Upvotes: 0
Views: 111
Reputation: 44633
str
in the method is an autoreleased object. Make it a copy
property and do
self.str = [self.str stringByAppendingFormat:@"%i",a];
label1.text = self.str;
If str
is same as label1.text
then do this directly.
label1.text = [label1.text stringByAppendingFormat:@"%i",a];
Upvotes: 2