I’ve been trying to get a text view and a slider to be updated to the correct value when either one has been modified.
Using bindings, I’ve successfully linked each control to a CALayer’s “x” value position (layer.position.x). The layer does move when any of the controls are changed. However, when modifying one of the controls, I cannot get the other control to update itself to reflect the newly changed value.
I tried to implement my own setter and getter methods that align with the KVC standards, but the getter method I have is not getting called. I’m thinking because it’s a primitive value that I’m modifying directly, the KVO for that value is not there. Is there a way to do this with bindings?
Thank You,
Charles
Text views, text fields, and CALayers are all in the view layer of the MVC pattern. You’ll have much better results by binding all of those views to a property of your controller.
If I had to guess a specific reason why binding to the layer doesn’t work, I’d point to Core Animation’s extensions to KVC, and guess that the automatic KVO magic doesn’t work with it.
I don’t think CALayers expose any bindings, so you’re just going to have to make the controller’s setter explicitly propagate the change to the CALayer.