की तुलना में मैं किसी उपयोगकर्ता को डेट पिकर के साथ भविष्य में दिनांक चुनने के लिए मजबूर करने की कोशिश कर रहा हूं। मैंने स्पष्ट रूप से तुलना का उपयोग किया: विधि, हालांकि, जब मैं निम्नलिखित कोड करता हूं, भले ही यह [NSDate दिनांक] के समान दिनांक है, तो यह बताता है कि अगर कथन निष्पादित करता है।एनएसडीएटी की तुलना [एनएसडीएटी तिथि]
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];
}
क्या आपने तुलना करने के लिए 'laterDate:' (या 'beforeDate: ') का उपयोग करने का प्रयास किया है? – gerry3
क्या होता है यदि आप तारीख को एनएसएलॉग देखते हैं कि यह सही मूल्य है या नहीं। –