inessential by Brent Simmons

Vesper Mac Diary #3 - Hiding Window Title

I wanted to try that new thing where you can hide the window’s title bar.

I have a window with a toolbar in a storyboard, so the first place I looked was in Interface Builder. I didn’t see anything there for setting this property.

No big deal. (rdar://17501388.) Some things don’t make into IB, or they make it later on. Easy enough to do in code.

So I created an NSWindowController subclass and assigned it to the window controller in my storyboard.

Then in windowDidLoad I added the following line:

self.window.​titleVisibility = NSWindowTitleHidden;

That should do it. But it didn’t — windowDidLoad doesn’t get called. (At least for storyboards, or at least for this one.) (rdar://17501206.)

Next I created an awakeFromNib method and added that same line of code there. It worked! In case you’re wondering how to do this, now you know.

Special note about Swift

I’m not writing code in Swift, just because when things go wrong — as they did above — using Swift adds an additional element of uncertainty, since Swift isn’t shipping yet.

(I wish I were writing in Swift, because it looks like fun. I’ll wait.)

But I did make a classic mistake right at first:

self.window.​titleVisibility = NO;

This translates to self.window.​titleVisibility = NSWindowTitleVisible;, which is not what I meant.

Would Swift have caught this bug for me? I suspect it would have.