I'm trying to use KVO in Swift, but the method "observeValueForKeyPath" is called once.
Here's a GIST of my code
I tried to use NSNumber
instead of Int
, add all options to addObserver
, but the method is still call once when my view load.
Any idea ?
EDIT: It seems like I found a temporary solution using:
var lifes: Int {
willSet {
willChangeValueForKey("lifes")
}
}