swiftproperty-observer

Swift call a method after 2 bool didset call


I have 2 bool with a didset method. Inside both didset it called a same method. So I want to call a method after that 2 bool did sets called

var canDo: Bool {
    didSet {
        reload()
    }
}

var isView: Bool {
    didSet {
        reload()
    }
}

Solution

  • var canDo: Bool {
        didSet {
            if isView{
                reload()
            }
    
        }
    }
    
    var isView: Bool {
        didSet {
            if canDo{
                reload()
            }
    
        }
    }