Sto tentando di forzare un utente a selezionare una data futura con un selettore di date. Ovviamente ho usato il metodo comparativo: tuttavia, quando faccio il seguente codice, anche se è la stessa data di [data NSDate], dice che esegue l'istruzione if. Qui è il mio codice:Confronto di un NSDate a [Data NSData]
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];
}
Hai provato a usare 'laterDate:' (o 'beforeDate:') per fare il confronto? – gerry3
Cosa succede se NSLog la data solo per vedere se ha il valore corretto. –