这是以前在 Swift2.3 中编写的代码,现在我在 swift3 中升级,因此出现错误 immutable value 'self.calender' may not be allocate to in swift3 我如何删除它?
class DateNSDateConverter
{
/// The singleton instance
static var sharedConverter = DateNSDateConverter()
let calendar: Calendar
let utc: TimeZone
init() {
calendar = Calendar(identifier: Calendar.Identifier.gregorian)
utc = TimeZone(abbreviation: "UTC")!
calendar.timeZone = utc; // error come here in this line
}
最佳答案
与
let
你使对象不可变。更改以下内容:
let calendar
到
var calendar
关于swift - 不可变值“self.calendar”可能不会在 swift 3 中分配给,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40650290/