J'ai un fichier UITableViewCell et à l'intérieur de celui-ci que je fais:Comment ajouter correctement Key-Value Observer à mon bouton?
var followers: FollowersModel? {
didSet {
self.followerButton.addObserver(self, forKeyPath: "followerButtonTapped", options: .New, context: &kvoContext)
}
}
override func observeValueForKeyPath(keyPath: String?, ofObject object: AnyObject?, change: [String : AnyObject]?, context: UnsafeMutablePointer<Void>) {
print(keyPath)
}
où
private var kvoContext = 0
Alors, je veux: Lorsque je clique sur le bouton dans les cellules, il courra la fonction de la ViewController. Mais en cliquant sur mon bouton ne imprime rien.
C'est la première fois que je fais du KVO, est-ce que je fais quelque chose de mal?