For example when you start Xcode, a welcome window appears. You select recent project and Xcode opens a new window with your project and closes the welcome window. After you close the project window, only main menu is visible. And开发者_如何学编程 if you click on Xcode icon in the dock, welcome window will appear again.
So the question is how to make my welcome window open if a user clicks on the dock icon?
You can do this using a custom application delegate. When the application is opened from the finder or dock, if it has no windows it will call applicationOpenUntitledFile:
on it's delegate (as long as you don't override other methods to prevent it). You can use that method to display a welcome window. I would also suggest creating a custom window controller for your window to handle all document actions (i.e. open and new) so that you can hide the window if the user creates a document using the menu bar. See the NSApplicationDelegate reference.
精彩评论