I have a Swift code like this:
private var myVar = 0 {
didSet {
DispatchQueue.main.async { [weak self] in
if let myVar = self?.myVar {
if myVar > 0 {
// Do some UI stuff, access myVar again
}
}
}
}
}
My question is do we always have to go through the pain 'if let myVar = self?.myVar' and then check myVar, specifically here where we are in didSet block of the same variable?