cocoa - How to reference/open a window in Objective-c -


i need reference single window in app. if tick off "visible @ launch" shows up.

i keep seeing code following doesn't make sense. how self know window in nib file if not declared anywhere in interface?

nswindow *window = [self window];  

when run in applicationdidfinishlaunching, error:

no visible @interface 'appdelegate' declares selector 'window' 

that makes sense, because no interface declared. yet how window loading automatically when 'visible @ launch' ticked?

my end goal need reference window , change level, i.e.

[window setlevel:nsfloatingwindowlevel]; 

please help?

the short answer is:

in appdelegate.h, declare "window" property:

 @property (strong) iboutlet nswindow* window; 

in mainmenu.nib, connect main window "window" property of "appdelegate":

right-click on "appdelegate" object, click on widget next "window" property , drag window.

your "appdelegate" instance have "window" property, , assigned main window.


Comments

Popular posts from this blog

PySide and Qt Properties: Connecting signals from Python to QML -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

scala - 'wrong top statement declaration' when using slick in IntelliJ -