私に「Expression Result Unused」という警告を与えるコードがあります。私は何が間違っているのか分かりません。助けてください!「Expression Result Unused」という警告が表示されるのはなぜですか?
probsPerDayLabel.text = [NSString stringWithFormat:@"Do %i problems today.", task.probsPerDay];
私に「Expression Result Unused」という警告を与えるコードがあります。私は何が間違っているのか分かりません。助けてください!「Expression Result Unused」という警告が表示されるのはなぜですか?
probsPerDayLabel.text = [NSString stringWithFormat:@"Do %i problems today.", task.probsPerDay];
バージョン、th task.probsPerDayの結果は完全に使用されず、%i
は数字に置き換えずに、ラベルのテキストは「今日は何%問題ですか?」となります。
この行を::
probsPerDayLabel.text = @"Do %i problems today.",task.probsPerDay
は次のようになります。あなたは
probsPerDayLabel.text = [NSString stringWithFormat:@"Do %i problems today.",task.probsPerDay];
あなたはこのように、NSString
のstringWithFormat:
方法を使用している必要があり
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
}
@Joe:それは当てはまりません。ポインタエラーに変換された整数を取得します。私はXcodeで試したことがありません。 – grahamparks
@Joe:いいえ、それは '(probsPerDayLabel.text = @"今日の%iの問題ですか? ")、task.probsPerDay;'と同じです。カンマは割り当てよりも優先順位が低くなります。 – grahamparks
それは正しいです。終わりの金曜日、私は家に帰る必要があります! – Joe