0
我試圖根據哪個是4個文本字段的最高intValue來更改UILabel。這裏是我的代碼,但是當我輸入和整數時,它打印的控制檯完全錯誤。例如「1」打印爲520387200從文本字段中讀取整數錯誤
這是我的代碼,關於我在做什麼錯誤的任何想法將不勝感激!謝謝!!
-(IBAction) upDateCalories{ NSLog(@"Update Calories has been fired"); if([breakfast.text intValue] > [lunch.text intValue] && [dinner.text intValue] && [snacks.text intValue]) { MostCalorificMeal.text = @"Breakfast"; NSLog(@"breakfast is highest"); } else if([lunch.text intValue] > [breakfast.text intValue] && [dinner.text intValue] && [snacks.text intValue]) { MostCalorificMeal.text = @"Lunch"; NSLog(@"Lunch is highest"); } else if([dinner.text intValue] > [breakfast.text intValue] && [lunch.text intValue] && [snacks.text intValue]){ MostCalorificMeal.text = @"Dinner"; NSLog(@"Dinner is highest"); } else if([snacks.text intValue] > [breakfast.text intValue] && [lunch.text intValue] && [dinner.text intValue]) { MostCalorificMeal.text = @"Snacks"; NSLog(@"Snacks is highest"); } NSLog(@"breakfast %d",breakfast); NSLog(@"lunch %d",lunch); NSLog(@"dinne %d",dinner); NSLog(@"snacks %d",snacks); }
感謝球員們,我的兩個帖子都能解決我所有的問題。再次感謝!! - user2579356剛剛編輯 – user2579356