Search code examples
objective-ciosnscalendarnsdatecomponents

What´s the difference between NSWeekOfYearCalendarUnit and NSWeekCalendarUnit


I have a NSCalendar:

what´s the Differnece beteween:

NSDateComponents *dateComponents;
dateComponents = [cal components:(NSWeekOfYearCalendarUnit ) fromDate: testDate ];
dateComponents = [cal components:(NSWeekCalendarUnit ) fromDate: testDate ];

They both return 10 for this week. Thanks


Solution

  • They are supposed to be the same.

    As shown in How to get a week number from NSDate consistently in all iOS versions?, there's apparently a bug in iOS 5 where they give different results.