Theocacao
Leopard
Design Element
Comment on "Using Delayed Messages in Cocoa"
by Frank Reiff — Sep 21
I'm afraid I'm with Scott on this one.

Whether or not the IBOutlet instance variables are set or not, I don't know (I assume they are) but the Cocoa Bindings controller layer setup is definitely not always properly finished when awakeFromNib is called.

My own projects have fairly complicated nib structures and awakeFromNib on my main controller gets called at least a dozen times during initialization. This may be because it is the File Owner of a number of nibs, but Scott's example definitely rings a bell with me.

I had always assumed that everything would be set up by the time the awakeFromNib message was received, but in practice this didn't happen. Now at least I know it should work like that.

My solution was to make the main controller the application delegate and to use the applicationDidFinishLaunching to do my own deterministic setup.

Waiting 1 second may work, but then again it may not always work and I guess that's not good enough.

I think the loading issue may be more to do with the sequence in which Cocoa bindings resolves its bindings; it is easy to imagine that resolving one binding may have a knock-on effect on another binding, say in a typical list / detail view.

Now is Cocoa Bindings intelligent enough to always set the values in a consistent order? How does it deal with potential infinite loops, e.g. setting binding A changes binding B which changes binding A which changes..?

Any information about exactly how Cocoa Bindings performs its own initializaition would be appreciated..
Back to "Using Delayed Messages in Cocoa"
Design Element

Copyright © Scott Stevenson 2004-2015