使用带格式的字符串将标签更改为整数

时间:2014-04-11 09:51:24

标签: ios objective-c stringwithformat

我希望每次用户点击按钮时,其内部的数字增加1.以下是执行此操作的代码。但是我希望它在括号中,例如(1)当他们按下按钮变为(2)等时我该怎么做? 感谢

-(IBAction)passButton:(id)sender{
passCounter = passCounter + 1;
passLabel.text = [NSString stringWithFormat:@"%i",passCounter];   
}

2 个答案:

答案 0 :(得分:0)

passLabel.text = [NSString stringWithFormat:@"(%i)",passCounter];  

答案 1 :(得分:0)

-(IBAction)passButton:(id)sender{
   passCounter++;
   passLabel.text = [NSString stringWithFormat:@"(%i)",passCounter];   
}