Xcode在components
的惰性实例化中没有看到我懒惰的实例化属性weekdayLetters
。我该如何解决这个问题?
DaysViewController.Type does not have a member named 'components'
lazy var weekdayLetters: [String] = {
for index in 0...Constants.kNumberOfWeekdays - 1 {
components.weekday = calendar.firstWeekday + index
...
}
return ...
}()
lazy var components: NSDateComponents = {
let comps = NSDateComponents()
comps.weekOfYear = 1
return comps
}()
lazy var calendar: NSCalendar = {
return NSCalendar.currentCalendar()
}()
答案 0 :(得分:2)
明确self.
解决了您的问题:
self.components.weekday = self.calendar.firstWeekday + index
^^^^^ ^^^^^
据我所知,没有关于此事的文件。