每次单击按钮时,我想将 1 添加到我的变量中,但会出现一个 10 位数字。我在下面的代码中做错了什么?
-(IBAction)recordData:(id)sender {
int randomNumber;
randomNumber = randomNumber + 1;
NSString *myRandomNumber = [NSString stringWithFormat:@"%i", randomNumber];
NSString *CompleteData = [[NSString alloc] initWithFormat:DataView.text];
CompleteData = [CompleteData stringByAppendingString: @"\n"];
CompleteData = [CompleteData stringByAppendingString:myRandomNumber];
DataView.text = CompleteData;
}