Reputation: 3301
I am using UIDatePicker
to select a date. When loading the view date picker minimum date was set with current date, For my specification I need to know is there any modification done in UIDatePicker
or not.
if ([[date_picker minimumDate] compare:[date_picker date]] != NSOrderedSame) {
printf("value modified");
}
I have tried with the above condition but its always not matching even though I have not modified the date. Am I doing anything wrong? How do I find that out?
Upvotes: 0
Views: 171
Reputation: 4320
Set control events for datepicker like this
[date_picker addTarget:self
action:@selector(pickerChanged:)
forControlEvents:UIControlEventValueChanged];
and in the pickerChanged method get its value
- (void)pickerChanged:(id)sender{
selectedDate=[sender date];
}
date comparison with
if ([initialDate compare:selectedDate]!=NSOrderedSame)
{
NSLog(@"modified");
// two dates are same and the date formatting of the two dates must be same
}
so whenever you change the date this method will be triggered initialDate is when the view loaded the value is set
Upvotes: 1