Skip to content

Instantly share code, notes, and snippets.

@jineshpaloor
Created November 6, 2015 05:58
Show Gist options
  • Save jineshpaloor/0f6e737fef82513b3243 to your computer and use it in GitHub Desktop.
Save jineshpaloor/0f6e737fef82513b3243 to your computer and use it in GitHub Desktop.
example to show how does didSet and willSet work
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