【发布时间】:2016-12-19 15:24:04
【问题描述】:
我在 Swift 中实现了我的 watch 项目,现在由于 Xcode 8 我正在迁移到 Swift 3。我让 Xcode 8 将源代码更改为 Swift 3。但是,代码中有错误,我无法弄清楚.
let unitFlags: Calendar = [.hour, .firstWeekday, .monthSymbols, .year, .minute, .firstWeekday]
var calendar = NSCalendar.current
calendar.timeZone = NSTimeZone(identifier: "UTC")!
let components = (calendar as NSCalendar).components(unitFlags, from: reservationDate)
Xcode 在这些行中出现错误,我无法理解问题所在。
错误:上下文类型“日历”不能与数组文字一起使用
错误:参数标签“(标识符:)”不匹配任何可用的 重载
错误:无法将“日历”类型的值转换为预期参数 输入“NSCalendar.Unit”
【问题讨论】: