Re: autoreleasing NSBezierPath object
Re: autoreleasing NSBezierPath object
- Subject: Re: autoreleasing NSBezierPath object
- From: Fritz Anderson <email@hidden>
- Date: Wed, 27 Jun 2001 11:49:37 -0500
At 8:38 PM -0700 6/26/2001, Oscar Bascara wrote:
Here's a newbie question.
In Learning Cocoa, the Dot View project calls the following line in
the drawRect: method:
[[NSBezierPath bezierPathWithOvalInRect:dotRect] fill];
Does the NSBezierPath object that gets created (allocated and
initialized) need to be autoreleased?
...
Or is it that the NSBezierPath object is autoreleased by default,
and if you really want it, you need to retain it?
That is the case. Class methods that provide convenient
allocation-and-initialization return autoreleased instances. If you
write [[ClassName alloc] init...] or [instance copy...], you are
responsible for the resulting object, and must release it. Otherwise
it's autoreleased already.
-- F