Please help me understand how the drawing works in First Animation. I am relatively new to Cocoa, but I’ve worked through several books (including Steinberg’s excellent Cocoa Programming), and several other tutorials, including several that subclass NSView. In every one of them the screen drawing is accomplished by drawRect and setNeedsDisplay. First Animation uses neither (as far as I can see).
The “Moving the Image” section on page 12 seems to say that the drawing is accomplished directly or indirectly by setFrame. But the Xcode documentation for the setFrame method of NSView says this: “This method, in setting the frame rectangle, repositions and resizes the receiver within the coordinate system of its superview. It neither redisplays the receiver nor marks it as needing display. You must do this yourself with display or setNeedsDisplay:.”
And the View Programming Guide says this: “None of the methods that alter a view’s frame rectangle automatically redisplay the view or marks it as needing display. When using the setFrame… methods, you must mark both the view being repositioned and its superview as needing display”
However, I put NSLogs before and after the setFrame statements, and setFrame clearly does set needsDisplay (or indirectly causes it to be set), for both subview “mover” and superview “self” (BaseView). But without a drawRect, what does the drawing?
So I’m very confused as to how First Animation draws the views. Could you please explain? Thanks!