Re: DotView.m
Re: DotView.m
- Subject: Re: DotView.m
- From: Graeme Phillipson <email@hidden>
- Date: Wed, 7 Nov 2001 10:34:18 +0000
Hello,
Just ben going through the same book myself.
On Wednesday, November 7, 2001, at 10:12 AM, Craig Bakalian wrote:
Is the [self setNeedsDisplay:YES] message firing the -(void)drawRect:
(NSRect)rect? I know this is not good MVC but couldn't DotView.m
replace
[self setNeedsDisplay:YES] with [self drawRect: (NSRect)frame?
But you need the frame in question (NSRect)frame. When you call the set
needs display it does a lot of work, like clearing what was there
before. I've also noticed that the NSView implements double buffering
for you, that is you draw not directly on the screen but into a
off-screen buffer which is copied onto the screen when your done. So I
suppose that maybe you could do the drawing directly then, but doing
setNeedsDisplay gives NSView a chance at doing a lot of extra work for
you.
And, on page 136 I quote, "2. Implement dealloc as shown. There's
nothing
unusual here:"
-(void)dealloc{
[color release]
[super dealloc]
}
I know Learning Cocoa is not a master's thesis, but the part about
"nothing
unusual here" is a tutorial that abandons the reader. My question is
when
the DotView.m is loaded into memory, it eventually has to be unloaded,
this
is the purpose of the above, but what is firing this method? Please
tell me
what is not unusual.
That does deallocate the resources that you acquired for your object.
Its not unusual because if you've been told to dealloc you must release
anything you acquired. You don't have to worry about when to dealloc,
because the AppKit framework is going to sort this out for you, it will
dealloc you if you do something that closes the Dot View window, like
click on the close button.
Hope that helps.
Graeme Phillipson.
References: | |
| >DotView.m (From: Craig Bakalian <email@hidden>) |