(I wish I could add this as a formatted comment on applefreak's answer, which is a pretty good one. But SO doesn't allow markup in comments.)
Apple's documentation for NSCalendar says:
Some calendars represented by this API may have to map their basic
unit concepts into year/month/week/day/… nomenclature. For example, a
calendar composed of 4 quarters in a year instead of 12 months uses
the month unit to represent quarters.
Now, this could be a lot clearer, but I think what Apple is saying is that normal calendars don't have "quarters" at all; they only have years, months (12 of them), and days. But you can subclass NSCalendar
(or create a new instance of NSCalendar
?) so that the year has only 4 months, and then call those months "quarters", and for the benefit of such subclasses Apple has pre-defined the quarter
property. This is horribly confusing; I bet there's a good story behind Apple's WTFery here.
Anyway, I agree with applefreak that you should be dealing in year/month/day dates anyway, not mucking around with mythical "quarters." After all, what would it even mean to "add", let's say, two quarters to March 31, given that Q3 is shorter than Q1? (And would the answer depend on whether this was a leap year?)
If what you really want is "an event recurring every year on January 1, April 1, July 1, and October 1," then you should write that. Don't even bother with "adding three months", which has the same problems as "adding one quarter".
BTW, other people here have noticed the quarter
WTF as well. For example: I want to get a quarter value in NSDateComponents class