for awakeFromNib: "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"
As I. Savant just pointed out: it's not whether the objects have been
instantiated and connected with each other. It's whether it's too
soon for [NSApp mainWindow] to return what you think it does. You
can check this with an NSLog that prints the value of [NSApp
mainWindow] just before you send -setToolbar:.
Offhand it doesn't seem like you should use -mainWindow for this kind
of messaging anyway. "Main window" has a specific meaning in Cocoa
which may not be what you think it is.