I have a requirement below,
- First need to select date.
- Then app need to show the reminder options like (2 weeks before, 1 week before, 3 days before etc..,)
- If the selected date is two days from now then I need to disable the 2 weeks before and 1 week before option.
below is the code am using but not working,
- (IBAction)timePicker:(id)sender {
selectedTimeRow = [sender tag];
NSDate *date2=[NSDate date];
NSDate *DaysAgo;
if (selectedTimeRow==0) {
DaysAgo = [date2 dateByAddingTimeInterval:14*24*60*60];
NSLog(@"14 days ago: %@", DaysAgo);
}else if (selectedTimeRow==1){
DaysAgo = [date2 dateByAddingTimeInterval:7*24*60*60];
NSLog(@"7 days ago: %@", DaysAgo);
}else if (selectedTimeRow==2){
DaysAgo = [date2 dateByAddingTimeInterval:3*24*60*60];
NSLog(@"3 days ago: %@", DaysAgo);
}else if (selectedTimeRow==3){
DaysAgo = [date2 dateByAddingTimeInterval:1*24*60*60];
NSLog(@"1 days ago: %@", DaysAgo);
}
NSDateFormatter *format = [[NSDateFormatter alloc] init];
format.dateFormat = @"dd/MM/yyyy";
NSString *dateNew=[format stringFromDate:DaysAgo];
UIButton *button = (UIButton *)sender;
UITableViewCell *cell = (UITableViewCell*)[button superview];
//
NSComparisonResult result = [dateNew compare:_SavedDate];
if(result == NSOrderedAscending)
{
NSLog(@"date1 is later than date2");
cell.userInteractionEnabled=NO;
}else if (result == NSOrderedDescending) {
NSLog(@"date1 is earlier than date2");
[self calltoolrBar];
cell.userInteractionEnabled=YES;
}
else
{
NSLog(@"date1 is equal to date2");
[self calltoolrBar];
cell.userInteractionEnabled=YES;
}
}