Create NSWindow programmatically?

Question for Shane:

I was looking through your “Everyday” and “Explored” books, but all the examples of NSWindow assume the reader is building them in IB.

Is it possible to do this programmatically in SD6? I had a go but got lost and gave up. I think adding various controls would be fairly easy, but I couldn’t figure out how to actually produce a NSWindow with a view to put them in.

Yes, you just use - initWithContentRect:styleMask:backing:defer:.

There are actually quite a few samples here:

You just need to be careful of the threading issues.