Hi all,
At the end of each chapter, are little, I guess, extra bits of knowledge, for the "more curious" as to the workings of Cocoa. Well, unfortunately, I am one of those curious..and am not sure if the author means that the reader should be able to use the book's prior information presented to solve these issues. Anyway, perhaps the list would not mind if I delve into this a little more deeply. (Chapter 7...Key-Value coding, Key-Value Observing)
The issue is how to ( if I read this correctly) establish KVO programmatically.
Hillegass says: ( Here, the set up is... briefly. A window with a slider, and a label. The slider is bound to the AppController which acts as model/controller, updating a property of the AppController. In the initial setup, the label is bound to the property as an observer, and is updated for any changes in the value of the property...which works as expected.)
Using this code.
From the appleDocumentation:
I am trying to programmatically ( being more curious ) to do this, but there are many areas of confusion for me.
1)
Does Apple's documentation mean that each object in the nib, once fully initialized receive an "awakeFromNib"...so, Window will be loaded, and then once ready, Window will receive and awakeFromNib, or as **each** object within window is ready, ( slider, button, textfield) **each** one will receive an awakeFromNib?
2) As the code used by Hillegas is an instance method, **where** would one place this code. It seems to imply that it would have to be placed in a class that represented the label? Or is this really just a curiosity, and not practical?
Thank you in advance?
At the end of each chapter, are little, I guess, extra bits of knowledge, for the "more curious" as to the workings of Cocoa. Well, unfortunately, I am one of those curious..and am not sure if the author means that the reader should be able to use the book's prior information presented to solve these issues. Anyway, perhaps the list would not mind if I delve into this a little more deeply. (Chapter 7...Key-Value coding, Key-Value Observing)
The issue is how to ( if I read this correctly) establish KVO programmatically.
Hillegass says: ( Here, the set up is... briefly. A window with a slider, and a label. The slider is bound to the AppController which acts as model/controller, updating a property of the AppController. In the initial setup, the label is bound to the property as an observer, and is updated for any changes in the value of the property...which works as expected.)
How did the text field become an obsever of the "fido" key in the AppController Object? When it wakes up from the nib, the text field adds itself as an observer.
Using this code.
Code:
[AppController addObserver:self forKeyPath:fido options:KeyValueObservingOld context:somePointer]
From the appleDocumentation:
An awakeFromNib message is sent to each object loaded from the archive, but only if it can respond to the message, and only after all the objects in the archive have been loaded and initialized. When an object receives an awakeFromNib message, it is guaranteed to have all its outlet instance variables set.
I am trying to programmatically ( being more curious ) to do this, but there are many areas of confusion for me.
1)
Does Apple's documentation mean that each object in the nib, once fully initialized receive an "awakeFromNib"...so, Window will be loaded, and then once ready, Window will receive and awakeFromNib, or as **each** object within window is ready, ( slider, button, textfield) **each** one will receive an awakeFromNib?
2) As the code used by Hillegas is an instance method, **where** would one place this code. It seems to imply that it would have to be placed in a class that represented the label? Or is this really just a curiosity, and not practical?
Thank you in advance?