ibireme / YYCategories

A set of useful categories for Foundation and UIKit.
MIT License
826 stars 218 forks source link

NSDate分类的一个方法看不懂,能否介绍一下 #19

Closed WangGuibin closed 8 years ago

WangGuibin commented 8 years ago
- (NSInteger)yearForWeekOfYear {
    return [[[NSCalendar currentCalendar] components:NSCalendarUnitYearForWeekOfYear fromDate:self] yearForWeekOfYear];
}

weekOfYear 我知道是一年有多少个星期,yearForWeekOfYear ,表示英文差,难以理解哦...

ibireme commented 8 years ago

以 "NSCalendarUnitYearForWeekOfYear" 去搜索,应该能有不少结果。

WangGuibin commented 8 years ago

噢噢

ColinHwang commented 8 years ago

最近也看到这个东西 http://stackoverflow.com/questions/29025462/difference-between-year-and-yearforweekofyear-ios-nsdatecomponents 和里面的wiki看下就可以了