Change background of window in Cocoa

cocoa, macos, objective-c

Solution

From the AppDelegate you can simply invoke the `window` property

self.window.backgroundColor = [NSColor whiteColor];

otherwise from any point of you application you can call

[[NSApplication sharedApplication] keyWindow].backgroundColor = [NSColor whiteColor];

`keyWindow` is the currently "on top" window, which is probably the only one if the application is simple. For more complicated scenarios where you need a different window you can use

[[NSApplication sharedApplication] windows]

which will return an array of all the windows owned by the application.

Problem

Objective-C/Cocoa noob here. I'd like to make the window color in a little Mac app I'm making white, instead of the default light grey color. What's the proper way to do this?

Original source