[fbcocoa] Re: [fbcocoa] Cocoa question

Message: < previous - next >
Home   : June 2011 : Group Archive : All Groups

From: Brian S <fblistserve@...>
Date: Wed, 1 Jun 2011 18:13:21 -0700
On Jun 1, 2011, at 5:03 PM, Robert Covington wrote:

> For any given window, you can supposedly alter it's drawRect method and there you go, custom drawing.
I’m a beginner too, so hopefully someone knowledgeable chimes in.


As a developer you don’t tell your views to draw---Cocoa handles that for you. You only need to wait for the drawRect: method to be called ( it is called automatically for an NSView when it needs to be redrawn ). drawRect: may be overridden in a given Class. drawRect: can be called many times per second, so it needs to be well-written. For example, any window object locations could be calculated once and stored in instance vars for the object’s class.


> What I am wondering is given multiple instances of a windows, does that function reside in some @implementation file? And is it unique to each?
yes, it is overridden in an implementation section of code( technically an interface and implementation don’t have to be in separate files ).

Scott Stevenson in "Cocoa and Objective-C - Up and Running" explains drawRect: much better than me and, as a bonus, knows what he is doing. I’ll read the rest of your post tomorrow and see if I’m able to write some cogent( and maybe even accurate ) response to your other questions.


Brian S