How to tell when Cocoa MainMenu controls have been loaded
How can I tell when all of the MainMenu nib controls (primarily the main window) have been loaded? I want to display a sheet on top of the main window at launch, but when I put call beginSheet inside of awakeFromNib, I get an error because no windows have been开发者_JS百科 displayed yet: : kCGErrorIllegalArgument: _CGSFindSharedWindow: WID -1
How can this be fixed?
For this type of action, I'd suggest using the -applicationDidFinishLaunching delegate method. You'll implement this in your application delegate. Start the sheet from there and you're guaranteed that MainMenu.nib/xib is loaded by then.
精彩评论