How to add one month to an NSDate?

or azran picture or azran · Nov 14, 2011 · Viewed 58.7k times · Source

How To Add Month To NSDate Object?

NSDate *someDate = [NSDate Date] + 30Days.....;

Answer

TheEye picture TheEye · Nov 14, 2011

You need to use NSDateComponents:

NSDateComponents *dateComponents = [[NSDateComponents alloc] init];
[dateComponents setMonth:1];
NSCalendar *calendar = [NSCalendar currentCalendar];
NSDate *newDate = [calendar dateByAddingComponents:dateComponents toDate:originalDate options:0];
[dateComponents release]; // If ARC is not used, release the date components