Q:  I am trying to draw something to my view and am getting the message:

Assertion failed: No REAL window during lockFocus on a view

I've checked and the window instance variable of the view is non-nil.  Why am I getting this message?

A:  A REAL window is a PostScript window.  Your check for a non-nil window assures that you have a AppKit-side window, but it doesn't check to make sure there is an associated PostScript window.  When you grab a window in InterfaceBuilder, it is deferred by default.  When a window is deferred the associated PostScript window won't be created until you actually bring that window on screen.  You cannot draw to a window which doesn't yet have a PostScript window.   You can change the deferred status using the "Deferred" switch button on the InterfaceBuilder Window inspector or with the proper argument to the Window method (initContent:style:backing:buttonMask:defer:).  If you're ever in doubt about a view's status, you can use the canDraw method which returns a boolean which indicates whether you are able to draw to that view.

QA774

Valid for 1.0, 2.0, 3.0