Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
Drawing
Your custom view doesn’t do any drawing yet, so let’s change that. When I’m putting together a custom view, I usually like to know where the edges of the view are. I find it useful to draw a rectangle at the edge of the view, so that
I can see where the application is placing my view.
I know when something I’ve drawn has been drawn correctly, fully within the view.
Each NSView subclass has a specific rectangle of space, within which any drawing it does will occur. Sometimes your app will make calculations about where it should draw next, and sometimes those calculations will tell Cocoa to draw outside the rectangle — even though your calculations should have made it draw only within the rectangle. When I added the custom WorkbenchView to my project’s window, I didn’t resize it to fill the entire window.