It seems, that there is an issue with iOS5 NSDateComponents NSWeekCalendarUnit property.
It returns one week ahead the current, however it returns the correct number on iOS 4.
You can test it with the following code:
NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
NSDateComponents *weekComponents = [gregorian components:(NSWeekCalendarUnit) fromDate:[NSDate date];
NSInteger weekNr = [weekComponents week]
Update I have tested NSWeekOfYearCalendarUnit or NSWeekWeekOfMonthCalendarUnit (available in iOS 5 only), and they still return incorrect value, so currently the best solution is to check iOS version and modify the number manually.
Did you solve it?
Setting the weekday doesn’t work either.
No, I did version check and modified the value manually by -1. I hope it will show 2 for 2012 January 1…
Use NSWeekOfYearCalendarUnit or NSWeekWeekOfMonthCalendarUnit
Thanks, I will update the post!
Sorry, I have tested it out, but these values also return the bad week number (current + 1)…