我写了一些糟糕的代码,但它有效。有没有更好的方法来写这个?_decade.x 是 NSButton。
int baseDecade = 1940;
NSString *title;
int currentDecade = 0;
- (IBAction)nameDecade:(id)sender {
currentDecade = baseDecade;
title = [NSString stringWithFormat: @"%ld", (long)currentDecade];
_decade1.stringValue = title;
currentDecade = currentDecade +10;
title = [NSString stringWithFormat: @"%ld", (long)currentDecade];
_decade2.stringValue = title;
currentDecade = currentDecade +10;
title = [NSString stringWithFormat: @"%ld", (long)currentDecade];
_decade3.stringValue = title;