objective c - How to close first window programmatically in Cocoa Mac? -


i want click button on first window open second window , close 1st window @ same time similar one. button handler in appdelegate class , doesn't have [self close] how close window programmatically in cocoa mac?

how close 1st window? should create xib 1st window , load appdelegate?

if app delegate doesn't have iboutlet ivar or property first window add 1 , use reference close first window. create new window (ether programaticly or using makekeyandorderfront method on iboutlet ivar or property second window (which shouldn't have it's "visible @ launch" behavior set)).

// close front window… nsarray *orderedwindows = [nsapp orderedwindows]; nswindow *frontwindow = orderedwindows[0]; [frontwindow close];  // create new window… nsrect windowrect = nsmakerect(0., 0., 640., 480.); nsuinteger stylemask =  nstitledwindowmask | nsclosablewindowmask | nsminiaturizablewindowmask | nsresizablewindowmask; nswindow * newwindow = [[nswindow alloc] initwithcontentrect:windowrect stylemask:stylemask backing:nsbackingstoreretained defer:yes]; 

Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -