Observing an attribute of an attribute of App Delegate


#1

I’ve been enjoying the book very much thus far. However, in running some of my own experiments, I’ve run into trouble.

In Chapter 7, we learn to bind the value of various graphical objects to int fido, which happens to be an attribute of the App Delegate. When I try to do the same thing for an attribute of an attribute of App Delegate, things don’t seem to work in the same way as before anymore.

More precisely, I have create a new class Remote and give it an attribute int fido in the same way as was done for App Delegate in the book:

@interface Remote : NSObject { int fido; } @property (readwrite,assign) int fido; ...

The getters and setters are implemented with methods that log the read or written values.

I created an attribute of AppDelegate to refer to an instance of Remote:

@interface AppDelegate : NSObject <NSApplicationDelegate> { Remote *myRemote; } @property (strong) Remote *myRemote;

myRemote is instantiated in awakeFromNib. Remote also has an increment method that increases the value of fido by 1 by means of the getter and setter methods. The increment method is called for myRemote when a button is pressed in the interface.

Finally, various GUI objects in the interface builder have their value bound to App Delegate with Model Key Path

The interface builder accepts this and even helps me autocomplete this entry. Nevertheless, none of the GUI objects seem to be able to observe changes in the value myRemote.fido. Moving the slider does change the value of myRemote.fido and pressing the increment button increases its value. In both cases, the setter method is called.

What am I missing here? Is Key-Value Observation of an attribute of an attribute of App Delegate somehow crucially different from Key-Value Observation of an attribute of App Delegate?