用途NSCalendarUnitYear
:
NSCalendarUnit unitFlags = NSCalendarUnitYear | NSCalendarUnitMonth | NSCalendarUnitDay;
我从原始问题中的代码示例中推断出您正在寻找Objective-C答案,但对于那些寻找Swift等效的人,您会这样做:
let unitFlags: NSCalendarUnit = [.Year, .Month, .Day]
注意,在Swift 3中,等效的是:
let unitFlags: Set= [.year, .month, .day]