developer developer - 1 year ago 194
iOS Question

NSYearCalendarUnit deprecated in iOS

I'm using

but unfortunately, these "Calendar Units" are reported as deprecated first in
IOS 8.0
What's the alternative of them, or how do I avoid these warnings.

unsigned unitFlags = NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit;

Rob Rob
Answer Source

Use NSCalendarUnitYear:

NSCalendarUnit unitFlags = NSCalendarUnitYear | NSCalendarUnitMonth |  NSCalendarUnitDay;

I infer from the code sample in the original question that you were looking for Objective-C answer, but for those looking for Swift equivalent, you would do:

let unitFlags: NSCalendarUnit = [.Year, .Month, .Day]

Note, in Swift 3, the equivalent would be:

let unitFlags: Set<Calendar.Component> = [.year, .month, .day]
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download