How to correctly declare a Calendar Unit Component in iOS9? Here's what i did, and it fails..
let cal = NSCalendar.currentCalendar()
var comps = cal.components(.CalendarUnitYear | .CalendarUnitMonth | .CalendarUnitDay | .CalendarUnitHour | .CalendarUnitMinute | .CalendarUnitSecond, fromDate: NSDate())
OptionSets are handled differently now in Swift 2.0 and use set syntax instead of bitwise operators to join and test them.
Option sets support set literal syntax, and set-like methods such as contains:
object.invokeMethodWithOptions([.OptionA, .OptionB])
object.invokeMethodWithOptions([])
if options.contains(.OptionC) {
// .OptionC is set
}
See the Xcode 7 beta release notes or either of the following threads for more info: