简体   繁体   中英

How to close a window from an instance of NSObject

I started a cocoa project, and it generated AppleDelegate.h, AppleDelegate.m and main.xib files for me. I created some buttons on the window, then create a new class (inherit from NSObject), in the class I do a little thing for button clicks. When one button is clicked, I want the current window to disappear, then a new window to up. My issue is that I manage to generate a new window when a button is clicked, but I can't figure out how to close the previous window. Do I need to generate my class from NSWindow, instead of NSObject?

Just in case, this maybe useful to someone else.

[[[NSApplication sharedApplication] mainWindow] close ]; 

is what I am looking for.

Thanks!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM