如何在每个显示文本的触摸按钮后打印空间

时间:2013-03-16 21:06:32

标签: ios objective-c

这是我与Objective C的第一天,我每次触摸按钮时都会尝试打印空间。非常感谢。

#import "ViewController.h"

@interface ViewController()

@end

@implementation ViewController

@synthesize display = _display;

-(IBAction)trickClicked:(UIButton *)sender{
    NSString *trick = [sender currentTitle];

    UILabel *myDisplay = self.display;
    NSString *currentText = myDisplay.text;
    NSString *newText = [currentText stringByAppendingString:trick];
    myDisplay.text = newText;

}

@end

1 个答案:

答案 0 :(得分:1)

试试这个:

// NSString *newText = [currentText stringByAppendingString:trick];
NSString *newText = [NSString stringWithFormat: @"%@ %@", currentText, trick];