i.e. I have a layer's "transform.rotation.z" value which may change several times. Every time that value changes, I'd like to call a method. Of course I could call it just at any point where I touch that value. But maybe there's a more elegant way in objective-c / cocoa-touch? Somebody told me a few days ago that there's some notification mechanism available. But is that useful for something like this? How would it look like?
+1 for making me question my worldview - I didn't know KVO was present on the phone. I guess that's because Bindings isn't used in the SDK, so I made a rash assumption.
Graham Lee
2009-08-11 12:52:11
Thx! I was reading about KVO that "direct ivar access does not produce notifications". Can you tell how I would have to access the transform.rotation.z of the transform matrix of an view if I wanted to observe that keyPath?
HelloMoon
2009-08-11 13:43:09
Doesnt work! I tried it. "transform.rotation.z" as keyPath is not KVO-compliant.
HelloMoon
2009-08-11 14:14:22
Sorry about that. What's weird is that if you observe key path "transform.rotation" instead of "transform.rotation.z", it thinks it's KVO-compliant, but you get this verbose error "An instance 0xd41f50 of class NSConcreteValue is being deallocated while key value observers are still registered with it. Observation info is being leaked, and may even become mistakenly attached to some other object. " Might be worth a bug report / feature request to make transform.rotation.z observable.
invalidname
2009-08-11 16:31:52
As a workaround add a property for "z" that simply sets the real transform z, then make that KVO compliant...I'd file a Radar on that though.
Kendall Helmstetter Gelner
2009-08-11 23:07:57