Hi all, I'm having issues with some code in Xcode 8 that obviously worked in Xcode 7 under Swift 2.3 here are both versions of the code, Swift 2.3 code commented out and the now not working Swift 3 Code.
The error message I get is Type 'Set<Calendar.Component> has no member 'day'
Any help much appreciated
The error message I get is Type 'Set<Calendar.Component> has no member 'day'
Code:
/* extension NSDate {
func dayOfWeek() -> Int? {
guard
let calender: NSCalendar = NSCalendar.currentCalendar(),
let component: NSDateComponents = calender.components(.Weekday, fromDate: self) else { return nil }
return component.weekday
}
} */
extension Date {
func dayOfWeek() -> Int? {
guard
let calendar: Calendar = Calendar.current,
let component: DateComponents = calendar.dateComponents(.day, from: self) else { return nil }
return component.weekday
}
}
Any help much appreciated