Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

add current day with one day after and one day before to date picker objective-C

I have a datepicker and I want to have just one row with 3 options: current day, one day after and one day before .

Would you help me to do that?

My question is, how can I add 'current day' with one day after and one day before ?


1 Answers

NSDateComponents *components = [[NSDateComponents alloc] init];
[components setDay:days];

NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
NSDate *end = [gregorian dateByAddingComponents:components toDate:[NSDate date] options:0];

Where days is an integer representing the days you want to add/subtract from the current day.

like image 124
andreamazz Avatar answered Dec 03 '25 23:12

andreamazz



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!