Question about KVO - Printable Version
+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Programming Languages & Scripting (/forum-8.html)
+--- Thread: Question about KVO (/thread-9175.html)
Question about KVO - jotapeh - Jul 16, 2011 09:09 AM
Hey guys, first time poster
Just wondering - I'm trying to write a pixeling program and learning quite a lot from the Apple Sketch demo code as I go. It has a comment in SKTWindowController.h that says this:
But I can't find a pair of graphicsController/setGraphicsController functions, or a synthesize declaration, or even an @property or an override of willChangeValueForKey.. nothing.
How is this possible? I don't get how you can be KVC and KVO compliant without any of this.
RE: Question about KVO - SethWillits - Jul 16, 2011 11:19 AM
"If no accessor is found, and the receiver’s class method accessInstanceVariablesDirectly returns YES, the receiver is searched for an instance variable whose name matches the pattern _<key>, _is<Key>, <key>, or is<Key>, in that order."
YES if the key-value coding methods should access the corresponding instance variable directly on finding no accessor method for a property, otherwise NO.
The default returns YES."
So there you go. But that's a bad practice IMO. If you're publicly exposing it you should be using public setter/getters so that it's obviously bindable.
RE: Question about KVO - jotapeh - Jul 16, 2011 02:24 PM
Ahh thank you. Man that's sneaky!