Reputation: 12395
I was told that awakeFromNib should be called only once so I was quite surprised to see it was called twice for my WindowController. I use IB to create my WindowController in MainMenu.xib, but to tell it what window xib file to load I added an init method to it.
When I debug the code, I find the first call to awakeFromNib triggered by this call stack. So basically [MyWindowController init] triggered the first call. Then the second call I guess was because of loading MainMenu.xib. Is that correct ?
Can someone cast some light on it?
BTW, I read some other questions similar to mine on stack overflow and some answer said it may because of file owen issue. So I particularly change the file owner of the window xib file to NSApplication. But awakeFromNib was still called twice for MyWindowController.
Upvotes: 0
Views: 987
Reputation: 447
From your question I understand that you are instantiating MyWindowController in IB and then in MyWindowControllers init you are loading a second nib with initWithWindowNibName:? If so, you will naturally receive two awakeFromNib calls. One when loading the NIB specified in your init method, the other when loading MainMenu.xib.
Upvotes: 1