Implicit calls?

When I added a new file of the type NSView to my project, Xcode creates a new applescript file and automatically adds stubs for initWithFrame_ and drawRect_ methods. If I add log statements inside each of these methods, when the program is run the log statement in the drawRect_ method executes once. What called this method? Is there an implicit call to this somewhere? I also have a mouseDown_ method in my program, and every time I click the mouse, the log statement in the initWithFrame_ method executes. Why does this happen - I have no explicit link between my mouseDown and the initWithFrame_ methods? [The applescript is called MyView, and I changed the class of the window’s content view to class MyView, added an NSBox to the view and mouseDown_, mouseDragged_ and mouseUp_ methods to drag the NSBox around the window. I didn’t add anything to the initWithFrame_ or drawRect_ methods except a log statement in each]

Hi,

to understand the concept of subclassing, please read View Programming Guide:
Creating A Custom View

Stefan has given probably the best answer, but you can actually cut those two handlers out. They are included in the template on the basis that you’re likely to want to modify them – you don’t, so they can go.

I’m not sure why initWithFrame_ is being called repeatedly – it shouldn’t. But drawRect_ should – that’s how the view gets drawn.