Created
November 6, 2015 05:58
-
-
Save jineshpaloor/0f6e737fef82513b3243 to your computer and use it in GitHub Desktop.
example to show how does didSet and willSet work
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var v : Int = 0 { | |
didSet{ | |
print("didSet called \(v)") | |
} | |
willSet(newValue){ | |
if (newValue != v){ | |
print("value changed") | |
} else { | |
print("value not changed") | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment