iDevGames Forums

Full Version: Question about KVO
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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:

This class is KVC and KVO compliant for this key:

"graphicsController" (an NSArrayController; read-only) - The controller that manages the selection for the graphic view in the controlled window.

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. Huh

"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."

"+ (BOOL)accessInstanceVariablesDirectly
Return Value
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.
Ahh thank you. Man that's sneaky!
Reference URL's