Bir kullanıcıyı ileride tarih seçiciyle bir tarih seçmeye zorlamaya çalışıyorum. Karşılaştırma yöntemini kullandım, ancak, aşağıdaki kodu yaptığımda, [NSDate date] ile aynı tarih olsa bile, if deyimini çalıştırır.Bir NSDate öğesinin [NSDate date] ile karşılaştırılması
if ([datePicker.date compare:[NSDate date]] == NSOrderedAscending) // If the picked date is earlier than today
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Hmm, this date is earlier than today"
message:@"The date you've selected is earlier than today's date, please pick another"
delegate:nil
cancelButtonTitle:@"Okay, I'll pick another"
otherButtonTitles:nil];
// Show the alert
[alert show];
// Release the alert
[alert release];
}
Karşılaştırmayı yapmak için 'laterDate:' (veya 'EarlyDate:') kullanmayı denediniz mi? – gerry3
Doğru değere sahip olup olmadığını görmek için tarihe NSLog yaparsanız ne olur? –