在此代码中,当文本发生更改时,titleEditingChanged会调用(如预期的那样).但是当它执行该行时
investment?.title = sender.text!
Run Code Online (Sandbox Code Playgroud)
它调用didset{}的Investment.为什么?
class InvestmentCell: UITableViewCell {
var investment: Investment? {
didSet {
// setup UI elements from class properties
textField.text = investment?.title
valueField.text = investment?.value?.description
}
}
@IBAction func titleEditingChanged(sender: UITextField) {
investment?.title = sender.text!
}
@IBOutlet weak var textField: UITextField!
@IBOutlet weak var valueField: UITextField!
}
Run Code Online (Sandbox Code Playgroud)