无法使用参数列表“(rawValue: UInt)”调用 'NSCalendar.Unit.Type' 类型的值

Cannot invoke value of type 'NSCalendar.Unit.Type' with argument list '(rawValue: UInt)'

Aster 将我的项目从 swift2.3 更新为 swift 3 我收到此错误:无法使用参数列表 '(rawValue: UInt)' 调用 'NSCalendar.Unit.Type' 类型的值 在 swift3 中,NScalender 重命名为 Calendar,但如何在此代码中使用日历 class?':

private func calendar(_ calendar: TKCalendar, eventsForDate date: Date) -> [AnyObject]? {
   let components = self.calendarView.calendar.component(NSCalendar.Unit(rawValue: NSCalendar.Unit.Year.rawValue|NSCalendar.Unit.Month.rawValue|NSCalendar.Unit.Day.rawValue), from: date)


    components.hour = 23
    components.minute = 59
    components.second = 59
    let endDate = self.calendarView.calendar.dateFromComponents(components)
    let predicate = NSPredicate(format: "(startDate <= %@) AND (endDate >= %@)", endDate!, date)
    let result: NSArray = self.events.filteredArrayUsingPredicate(predicate)
    return result as [AnyObject]
}

这是因为 swift 日历 class 发生了 3 次更改。

改为-

let components = self.calendarView.calendar.dateComponents([.day, .month, .year], from: date)