• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: autoreleasing NSBezierPath object
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: autoreleasing NSBezierPath object


  • Subject: Re: autoreleasing NSBezierPath object
  • From: Joe Muscara <email@hidden>
  • Date: Wed, 27 Jun 2001 14:42:41 -0500

Hello Oscar Bascara, I'm Joe Muscara! ;~)

You ask a very good question. I would consider myself a Cocoa newbie as well, so someone out there may do a better or more accurate job explaining this.

What I think is happening is that the NSBezierPath object is being autoreleased. You only need to worry about releasing/autoreleasing objects that you instantiate. Or to quote mmalcolm crawford,

"Objects created using convenience constructors (e.g. NSString's stringWithString) are considered autoreleased."
<http://www.stepwise.com/Articles/Technical/2001-03-11.01.html>

You should check out this article and the other ones on Stepwise that he references, and you should read them again, and again, and again... :~)

I think the way it works is that if you instantiate an object with an "alloc..." method, you need to release it. If the object is created via a built-in class method (or rather, "convenience constructor," and these usually seem to be named something like "classNameWith..." but are they always?) then it is considered autoreleased.

HTH
Joe

On Wednesday, June 27, 2001, at 12:36 PM, Oscar Bascara <email@hidden> 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?

[[[NSBezierPath bezierPathWithOvalInRect:dotRect] autorelease] fill];

The object is never explicitly released/autoreleased in the program.
Since drawRect: can be called many times, I'm just concerned about a
possible memory leak.

Or is it that the NSBezierPath object is autoreleased by default, and if
you really want it, you need to retain it?


  • Prev by Date: Frantic and Frustrated {Additional to previous}
  • Next by Date: NSTask & NSPipe
  • Previous by thread: Re: autoreleasing NSBezierPath object
  • Next by thread: NSTextView and First Responder
  • Index(es):
    • Date
    • Thread