Ich habe eine Datei UITableViewCell und es innerhalb von ich:Wie kann ich Key-Value Observer richtig zu meiner Schaltfläche hinzufügen?
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)
}
wo
private var kvoContext = 0
Also, ich will: Wenn ich in diesen Zellen auf die Schaltfläche klicken, wird es Funktion von der Flucht ViewController. Aber beim Klicken auf meine Schaltfläche wird nichts gedruckt.
Es ist mein erstes Mal mit KVOs, mache ich etwas falsch?