为什么我收到“表达式结果未使用”?警告?
我有一段代码给我一个“表达式结果未使用”警告。我不知道我做错了什么。请帮忙!
if(task.typeForThis.typeID == @"DivisionAT"){
probsPerDayLabel.hidden = NO;
whatToDoLabel.hidden = YES;
//int ppdi = task.probsPerDay;
//NSString *ppd = [NSString stringWithFormat: @"%i", ppdi];
probsPerDayLabel.text = @"Do %i problems today.",task.probsPerDay; //Right here
}
I have a piece of code that is giving me a 'Expression Result Unused' warning. I have no idea what I'm doing wrong. Please help!
if(task.typeForThis.typeID == @"DivisionAT"){
probsPerDayLabel.hidden = NO;
whatToDoLabel.hidden = YES;
//int ppdi = task.probsPerDay;
//NSString *ppd = [NSString stringWithFormat: @"%i", ppdi];
probsPerDayLabel.text = @"Do %i problems today.",task.probsPerDay; //Right here
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这一行:
应该是:
在您的版本中,task.probsPerDay 的结果完全未使用,标签上的文本将是“Do %i issues Today.”,而不会替换
%i
通过一个数字。This line:
should be:
In your version, the result of task.probsPerDay is completely unused, and the text on the label will be "Do %i problems today.", without the
%i
being replaced by a number.您需要使用
NSString
的stringWithFormat:
方法,如下所示:You need to be using the
stringWithFormat:
method ofNSString
, like this: