cocoa - What's the correct way to reopen a window on OSX? -


i've got app i've created in xcode. it's not document based.

how make when user clicks on say, dock icon, window reopens? i'm creating out nib xcode automagically gave me.

i've tried implement applicationshouldopenuntitledfile: , calling makekeyandvisible on app delegate's window property, messes app's icon. (i guess has icons serving document previews.)

regardless, i've googled bit, , found references carbon apis, or document based apps.

how window creation process work between nsapplicationmain , app's nib file, how can replicate process, , can so?

generally, find working nswindowcontrollers makes dealing windows much simpler. in case, app delegate wouldn't own window directly, instead own nswindowcontroller owns window.

to this, you'd create new nswindowcontroller subclass (with xib user interface), , migrate window mainmenu.xib new windowcontroller.xib. hook things up, , you're ready go. (also, make sure "visible @ launch" checkbox on window unchecked)

from app delegate, you'll create new instance of window controller (whether programmatically or via mainmenu.xib doesn't matter), , tell -showwindow: when want window show (or become key), , -close when want go away.

as responding clicking on dock icon, <nsapplicationdelegate> method you're looking -applicationshouldhandlereopen:hasvisiblewindows:.


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

android - Inheriting from Theme.AppCompat* -