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?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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.