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
}
This line:
probsPerDayLabel.text = @"Do %i problems today.",task.probsPerDay
should be:
probsPerDayLabel.text = [NSString stringWithFormat:@"Do %i problems today.",task.probsPerDay];
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:
方法,如下所示:
probsPerDayLabel.text = [NSString stringWithFormat:@"Do %i problems today.", task.probsPerDay];
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.