Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Window-less Cocoa application

I'm a complete beginner in Objective-C and Cocoa.

I would like to create a window-less application, which just shows a NSStatusItem in the system tray. The tray works fine, however, there is one problem.

For some reason my application automatically creates a window for me, which I do not want.

I thought it was caused by the automatic Interface Builder template created when I created the application in Xcode, so I deleted the .nib file from the project. However the window still gets created.

The only lines that contain a reference to the window are in the header:

NSWindow *window;
@property (assign) IBOutlet NSWindow *window;

and in the implementation file:

@synthesize window;

Both were added automatically, I did not write this.

How do I just stop the app from creating a window? I even tried to removing all references to window from the code, including the NSWindow *window, but the window still got created.

My temporary fix right now is to call [window close]; in the application, but surely there is a better way?

like image 395
houbysoft Avatar asked Jul 21 '11 23:07

houbysoft


Video Answer


1 Answers

My suspicion is that nothing in your code is creating the window. When you create a new Cocoa Xcode application, Xcode sets up an XIB with your interface for you. Open up MainMenu.xib (should be under Resources) in interface builder and delete the window that it throws in by default.

like image 69
Alex Nichol Avatar answered Sep 21 '22 02:09

Alex Nichol