I have tried so many things through the help I got, but I still can’t figure out how to do it properly. Here’s what I did lastly.
NSDateFormatter *tempFormatter = [[NSDateFormatter alloc]init];
[tempFormatter setDateFormat:@"dd-MM-yyy"];
NSDate *currentDate = [NSDate date];
NSDate *fromDate = [NSString stringWithFormat:@"%@",[tempFormatter stringFromDate:currentDate]];
NSLog(@"currentDate %@", fromDate);
NSDate *toDate = [NSString stringWithFormat:@"%@",[tempFormatter stringFromDate:datePicker.date]];
NSLog(@"toDate %@", toDate);
NSTimeInterval interval = [toDate timeIntervalSinceDate:fromDate];
double leftDays = interval/86400;
NSLog(@"Total interval Between::%g",leftDays);
Tell me what I did wrong. Is it the NSDate conversion, that I am not doing properly ??
Thanks.
This line is creating problem.
It changes the type of
toDatefrom NSDate to__NSCFString. TheNSTimeIntervaltake both of its arguments of NSDate type, but in your case onlyfromDateis NSDate type.Change your code with these lines
It will surely work (inshaAllah).