Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Two Way Binding in Swift

    • 0
    • 1
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 1.12k
    Comment on it

    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)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: