Hi All,
Two Way Binding :- In two way binding, data flows in both direction, from object to UI and vice-versa. For instance, you can have a UITextField
called as nameTF
which is binded with an object having property nameValue. So when the object value changes, it will be reflected on the iPhone UI, and UI element value will update whenever the nameValue property in the changed.
- First implement One Way Binding.
- Now, Add an observer for value changed in UITextField.
nameTF.addTarget(self, action: "textFieldDidChange:", forControlEvents: UIControlEvents.EditingChanged)
- Define method to handle value changed in textfield
func textFieldDidChange(textField:UITextField){
//your code
nameValue = textField.text!
}
Now whenever value changed in UITextfield value then it will reflect to your nameValue automatically.
0 Comment(s)