Reputation:
I have a date and I want to increment it by 1 month. How can I do this?
I'm new to iPhone programming. Can this be done or do I have to implement it myself?
Upvotes: 0
Views: 192
Reputation: 54445
You really need to use an NSCalendar for this type of activity, as this has methods like -dateByAddingComponents:toDate:options:
which will let you add "components" (NSDateComponents that represent 1 month or 1 year, etc. for example) onto an existing calendar date.
For some general background reading, you might also want to take a look at the Date and Time Programming Guide as it covers some of this, albeit quite briefly.
Upvotes: 3