我在Swift中實現了我的監視項目,現在我正在遷移到Swift 3,因爲Xcode 8。我讓Xcode 8將源代碼更改爲Swift 3.但是,代碼中存在錯誤,我想不明白。Xcode 8和Swift 3 NSCalendar
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在這些行中給出錯誤,我無法理解這個問題。
ERROR: Contextual type ' Calendar' cannot be used with array literal
ERROR: Argument labels '(identifier:)' do not match any available overloads
ERROR: Cannot convert value of type 'Calendar' to expected argument type 'NSCalendar.Unit'