我正在阅读文档NSCalendar
,出于好奇,我更深入地研究CFCalendarUnit
并看到了这一点:
typedef enum {
kCFCalendarUnitEra = (1 << 1),
kCFCalendarUnitYear = (1 << 2),
kCFCalendarUnitMonth = (1 << 3),
kCFCalendarUnitDay = (1 << 4),
kCFCalendarUnitHour = (1 << 5),
kCFCalendarUnitMinute = (1 << 6),
kCFCalendarUnitSecond = (1 << 7),
kCFCalendarUnitWeek = (1 << 8),
kCFCalendarUnitWeekday = (1 << 9),
kCFCalendarUnitWeekdayOrdinal = (1 << 10),
kCFCalendarUnitQuarter = (1UL << 11),
kCFCalendarUnitWeekOfMonth = (1UL << 12),
kCFCalendarUnitWeekOfYear = (1UL << 13),
kCFCalendarUnitYearForWeekOfYear = (1UL << 14),
} CFCalendarUnit;
我正在使用这个:
NSUInteger preservedComponents = NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit | NSHourCalendarUnit | NSMinuteCalendarUnit;
它回来了124
所以我尝试这样做:
NSUInteger preservedComponents = NSEraCalendarUnit | NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit;
我明白了30
。
我想不通。这个怎么运作?