0

Xcode does not see my lazily instantiated property components within lazy instantiation of weekdayLetters. How can I resolve this?

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()
    }()
Martin Koles
  • 5,177
  • 8
  • 39
  • 59

1 Answers1

2

Explicit self. solves your problem:

self.components.weekday = self.calendar.firstWeekday + index
^^^^^                     ^^^^^

As far as I know, There is no document about this.

rintaro
  • 51,423
  • 14
  • 131
  • 139