0
對,基本上我想把兩個數字加在一起。這是一個工作時間計算器,我已經包含了一個夜班場景的參數if語句。然而,它現在彌補了日班模式。所以我想弄清楚,如果開始時間低於12,那麼它將恢復到代碼中顯示的原始方程,而不是if語句。點與整數的比較
-(IBAction)done:(id)sender {
int result = [finishHours.text intValue] - [startHours.text intValue];
totalHours.text = [NSString stringWithFormat:@"%d", result];
if (result < 0) {
totalHours.text = [NSString stringWithFormat:@"%d", result * -1];
}
if (result < 12) {
totalHours.text = [NSString stringWithFormat:@"%d", result + 24];
}
if (startHours < 12) {
totalHours.text = [NSString stringWithFormat:@"%d", result - 24];
}
您可能想用語言(C#?)標記此語句。 – 2010-02-22 14:39:03
同時指定您期望的行爲,以及您得到的行爲,包括任何錯誤消息。 – outis 2010-05-09 05:18:41