I have some code that's breaking in Swift 2.0:
let formatter = NSDateComponentsFormatter()
formatter.allowedUnits = NSCalendarUnit.Year
formatter.allowedUnits |= .Month
formatter.allowedUnits |= .WeekOfMonth
formatter.allowedUnits |= .Day
formatter.allowedUnits |= .Hour
formatter.allowedUnits |= .Minute
I get the error Binary operator '|=' cannot be applied to 'NSCalenderUnit' operands
.
What's the new way of doing this kinda thing?
NSCalendarUnit
is anOptionSetType
in Swift 2, instead of aRawOptionSetType
. This means that you can't logical-or it anymore. Instead, you can use an array literal representation of it: