Rightpoint / RZDataBinding

Lightweight KVO-based data binding options.
Other
543 stars 57 forks source link

Binding UITextField.text to Model.property #53

Closed juliancorrea closed 8 years ago

juliancorrea commented 8 years ago

I try make the binding like this:

[self.company rz_bindKey:RZDB_KP(MMCompanyItem, contractName) toKeyPath:RZDB_KP(UITextField, text) ofObject:self.txContractName];

Doesn't works when change the value of UITextField, the property contractName on the object self.company doesn't reflects the change.

Am I doing something wrong?

jvisenti commented 8 years ago

Unfortunately some UIKit components don't provide KVO support :disappointed:

Programmatically setting the text of that text field will trigger your binding, but it won't be triggered as the user types. The most reliable way to observe a UITextField is to use the UIControl target/action API:

[self.txContractName addTarget:self action:@selection(textChanged) forControlEvents:UIControlEventEditingChanged]
juliancorrea commented 8 years ago

thanks jvisenti. I am doing just that.