How to make a Mac OSX Cocoa application fullscreen?

tobros91 picture tobros91 · Feb 7, 2011 · Viewed 23.7k times · Source

I have been trying to make my Mac application enter fullscreen now for a while but can't get it to work. According to the Apple developer center, I should use enterFullScreenMode:withOptions: which gives me, method enterFullScreenMode not found.

Everywhere I google there seems to be people having issues with making their app fullscreen, so what is the way to make it work?

Edit:

Of course enterFullScreenMode is for the NSView and I used it on a NSWindow; it's not the view I want to have fullscreen, but the window. I can't find any function for the NSWindow though.

Answer

Randall picture Randall · Oct 17, 2011

Lion has some new APIs for full screen.

To do it with NSWindow, do this

[window setCollectionBehavior:
          NSWindowCollectionBehaviorFullScreenPrimary];

To do this with NSApplication do this

[[NSApplication sharedApplication]
        setPresentationOptions:NSFullScreenWindowMask];

A bit more about it here.