I tried to use [weak self] in the didSet of the variable:
var data: Dictionary! {// [1]
didSet {[2]
self?.layoutSubviews()
}
}
Either [weak self] is in [1] or [ 2], I still get the error: Use of unresolved identifier is weak
Why is this? Is it illegal to use [weak self] for didSet?
Greetings,
There is no reason to use weak self there. The didSet handler does not create the ownership cycle in the same way as the method does not create the ownership cycle.
I rarely see people using [weak self] in didSet. Is there a reason?
I tried to use [weak self] in the didSet of the variable:
var data: Dictionary! {// [1]
didSet {[2]
self?.layoutSubviews()
}
}
Either [weak self] is in [1] or [ 2], I still get the error: Use of unresolved identifier is weak
Why is this? Is it illegal to use [weak self] for didSet?
Greetings,
didSet is not a closure, you cannot use closure syntax.
No The reason is to use weak self there. The didSet handler does not create the ownership cycle in the same way that the method does not create the ownership cycle.