class Samplepgm { var counter: Int = 0 { willSet(newTotal){ print("Total Counter is: \(newTotal)") } didSet { if counter > oldValue { print("Newly Added Counter \(counter - oldValue)") } } } } let NewCounter = Samplepgm() NewCounter.counter = 100 NewCounter.counter = 800
We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy. Accept Learn more