사용자가 지정된 시간 (예 : 13:00, 13:01, 13:02 등)을 입력하여 점수를 결정하는 UIPicker가 있습니다. 그들이 버튼을 누르면 경고가 'if-else'문을 통해 결정되는 점수를 얻습니다. 모든 것이 시간의 가장 큰 시간 동안 작동하는 것처럼 보입니다. 그러나 나는 이상한 행동을하고 있습니다. 이 코드는 다음과 같습니다.iPhone이 'if'문에서 이상한 결과를 내고 있습니다.
//Gets my value from the UIPicker and then converts it into a format that can be used in the 'if' statement.
NSInteger runRow = [runTimePicker selectedRowInComponent:2];
NSString *runSelected = [runTimePickerData objectAtIndex:runRow];
NSString *runSelectedFixed = [runSelected stringByReplacingOccurrencesOfString:@":" withString:@"."];
//The actual 'if' statment.
if ([runSelectedFixed floatValue] <= 13.00) {
runScore = 100;
} else if ([runSelectedFixed floatValue] <= 13.06) {
runScore = 99;
} else if ([runSelectedFixed floatValue] <= 13.12) {
runScore = 97;
} else if ([runSelectedFixed floatValue] <= 13.18) {
runScore = 96;
} else if ([runSelectedFixed floatValue] <= 13.24) {
runScore = 94;
} else if ([runSelectedFixed floatValue] <= 13.30) {
runScore = 93;
} else if ([runSelectedFixed floatValue] <= 13.36) {
runScore = 92;
} else if ([runSelectedFixed floatValue] <= 13.42) {
runScore = 90;
} else if ([runSelectedFixed floatValue] <= 13.48) {
runScore = 89;
} else if ([runSelectedFixed floatValue] <= 13.54) {
runScore = 88;
}
이제 프로그램을 테스트 할 때 '13 : 00 '('100 ')을 선택하면 예상되는 결과를 얻게됩니다. '13 : 01 ~ 13:05 '사이의 모든 시간을 선택하면'99 '의 예상 결과도 얻게됩니다. 하지만 '13 : 06 '을 선택하면 점수가'97 '이됩니다. 나는 또한 '13 : 07 ~ 13:12 '에'97 '이라는 점수를 얻습니다. 이것이 바람직한 결과입니다. 왜 나는 '13 : 12 '에'97 '권리를 얻을 것이지만 '13 : 06'에 '99'권리를 얻지는 못하겠습니까? 이 메모리 누수 또는 뭔가있을 수 ???
'[runSelectedFixed floatValue]'기록을 시도 했습니까? 기회는 플로트가 * 정확하게 * 13.06 아니지만 조금 더 ... –