I have a DatePicker control in my app. If I try to choose, for example, Jan 1, 2011, it returns Jan 1, 2010. If I choose Jan 1, 2040, I get Jan 1, 2039, and so on. Dec 31 and
if daycount
is truly 0
like you say in your comment, then that's likely the source of your problem. The day
property of an NSDateComponents
object should be in the natural range as defined by the calendar. In the case of the Gregorian calendar, that is 1-31. If the day is outside of that range, then units start wrapping around and you'll probably not get the result you want.