私がやろうとしているのは、記号よりも大きいよりも小さい日付を使用して if ステートメントを作成することです。何らかの理由で、大なり記号のみが機能します。これが私のコードです:
NSDate *currDate = [NSDate date];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc]init];
[dateFormatter setDateFormat:@"HHmm"];
NSString *dateString = [dateFormatter stringFromDate:currDate];
NSLog(@"%@",dateString);
if (dateString < @"0810" && dateString > @"0800") {
NSLog(@"Homeroom");
}
else {
NSLog(@"no");
}
時刻が 8:03 の場合、このコードの出力は次のようになります。
2013-04-08 08:03:47.956 Schedule2.0[13200:c07] 0803
2013-04-08 08:03:47.957 Schedule2.0[13200:c07] no
もし私がそうするなら、それは次のようにサインするだけです:
if (dateString > @"0800") {
NSLog(@"Homeroom");
}
else {
NSLog(@"no");
}
出力は次のようになります。
2013-04-08 08:03:29.748 Schedule2.0[14994:c07] 0803
2013-04-08 08:03:29.749 Schedule2.0[14994:c07] Homeroom