I have a class and a lazy var inside, like this:
class C {
lazy var btn = {
let btn = UIButton()
btn.addBlock { [weak self] self?.xxx() }
return btn
}
}
However, the compiler said: "Cannot find 'weak' in scope"
If I change to this, it works:
class C {
lazy var btn = {
let btn = UIButton()
weak var ws = self
btn.addBlock { ws?.xxx() }
return btn
}
}
So, can't we use "[weak xxx]" to weak something inside a block inside a lazy var property statement?