-(NSInteger)getTheUltimateWeekOfAYear:(NSInteger)year
{
NSDateComponents *comps = [NSDateComponents alloc];
[comps setDay:31];
[comps setMonth:12];
[comps setYear:year];
NSCalendar *usersCalendar =[[NSLocale currentLocale] objectForKey:NSLocaleCalendar];
NSDate *date = [usersCalendar dateFromComponents:comps];
NSDateComponents *weekComps =
[usersCalendar components:NSWeekCalendarUnit fromDate:date];
return [weekComps week];
}
`
嗨,这个片段在 iOS 5.1 模拟器上运行时错误地返回 1。我相信它应该返回 53。我做错了什么?顺便说一句,我的模拟器预设为公历。/约翰