How To Add Month To NSDate Object?
NSDate *someDate = [NSDate Date] + 30Days.....;
For example, to add 3
months to the current date in Swift:
let date = NSCalendar.currentCalendar().dateByAddingUnit(.MonthCalendarUnit, value: 3, toDate: NSDate(), options: nil)!
let date = NSCalendar.currentCalendar().dateByAddingUnit(.Month, value: 3, toDate: NSDate(), options: [])
OptionSetType
structure of NSCalendarUnit
lets you more simply specify .Month
OptionSetType
(like the options:
parameter, which takes NSCalendarOptions
) can't be nil
, so pass in an empty set ([]
) to represent "no options".