Beginnersquestion:NSMutableString append string
有三个按钮代表字母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;
}
谢谢你,我的标签显示连接错误。 再次进行连接,现在它工作! 再次感谢! – user2928201