Binary operator cannot be applied: NSCalendarUnit

Have the following code running in 7.0 beta (7A120f) - didn't see that as a topic in the "beta" forum...adjusting to the forum change.


let dateComponentsFormatter = NSDateComponentsFormatter()
dateComponentsFormatter.allowedUnits = NSCalendarUnit.Day | NSCalendarUnit.Hour | NSCalendarUnit.Minute | NSCalendarUnit.Second


Receiving the following build error: Binary operator '|' cannot be applied to two NSCalendarUnit operands.


Did not see this error in Xcode 6, not sure if this should be filed as a bug report at this juncture. Other solutions offered by the interwebs proving unviable.


Thoughts?


Cheers,

Josh

Answered by AMidKnight in 6616022

And, just in case the description in the documentation isn't clear enough:


let dateComponentsFormatter = NSDateComponentsFormatter()
dateComponentsFormatter.allowedUnits = [NSCalendarUnit.Day, NSCalendarUnit.Hour, NSCalendarUnit.Minute, NSCalendarUnit.Second]
let dateComponentsFormatter = NSDateComponentsFormatter()
dateComponentsFormatter.allowedUnits = [NSCalendarUnit.Day, NSCalendarUnit.Hour, NSCalendarUnit.Minute, NSCalendarUnit.Second]


http://adcdownload.apple.com/WWDC_2015/Xcode_7_beta/Xcode_7_beta_Release_Notes.pdf underSwift Language Changes

Accepted Answer

And, just in case the description in the documentation isn't clear enough:


let dateComponentsFormatter = NSDateComponentsFormatter()
dateComponentsFormatter.allowedUnits = [NSCalendarUnit.Day, NSCalendarUnit.Hour, NSCalendarUnit.Minute, NSCalendarUnit.Second]

Or just


let dateComponentsFormatter = NSDateComponentsFormatter()
dateComponentsFormatter.allowedUnits = [.Day, .Hour, .Minute, .Second]


since the enumeration type can be inferred from the context.

Binary operator cannot be applied: NSCalendarUnit
 
 
Q