【发布时间】:2013-10-28 13:24:16
【问题描述】:
初学者问题:
有三个按钮,分别代表字母 a、e 和 i。 按下按钮时,相应的字母应显示在标签中。 因此,当每个按钮按下一次时,标签会显示“aei”。 下面附上我的代码。现在按三下按钮时,标签 仅显示最后按下的按钮字母。 我究竟做错了什么? 感谢您的帮助!
#import "SecondViewController.h"
NSMutableString *stringLabel;
@interface SecondViewController ()
@end
@implementation SecondViewController
-(IBAction)type_a:(id)sender;{
[stringLabel appendString: @"a"];
NSLog(@"stringLabel is set to: %@", stringLabel);
label.text = stringLabel;
}
-(IBAction)type_e:(id)sender;{
[stringLabel appendString: @"e"];
NSLog(@"stringLabel is set to: %@", stringLabel);
label.text = stringLabel;
}
-(IBAction)type_i:(id)sender;{
[stringLabel appendString: @"i"];
NSLog(@"stringLabel is set to: %@", stringLabel);
label.text = stringLabel;
}
【问题讨论】:
标签: nsmutablestring