初学者问题:
有代表字母 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;
}