• 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: Brendan Younger <email@hidden>
  • Date: Wed, 27 Jun 2001 14:03:43 -0500

First of all, get far, far away from that book. From what I hear it's more a hindrance than help.
Second, you hit the nail on the head with: "Or is it that the NSBezierPath object is autoreleased by default, and if you really want it, you need to retain it?" For future reference, your question is about "convenience constructors." Any time you create an object without explicitly using -alloc -allocWithZone -copy, etc. the object returned to you is autoreleased already. For instance, this is what the code for -bezierPathWithOvalInRect: might look like:

+ (id)bezierPathWithOvalInRect:(id)rect
{
self = [[NSBezierPath alloc] initWithRect:rect];

return [self autorelease];
}

Therefore, [[[NSBezierPath bezierPathWithOvalInRect:dotRect] autorelease] fill]; will crash because the object will be autoreleased twice and this does bad things to memory.
Stepwise has a great article about this, check out http://www.stepwise.com/Articles/Technical/2001-03-11.01.html.

Brendan Younger


  • Follow-Ups:
    • Re: autoreleasing NSBezierPath object
      • From: "Dennis C. De Mars" <email@hidden>
References: 
 >autoreleasing NSBezierPath object (From: Oscar Bascara <email@hidden>)

  • Prev by Date: Re: field editor oddness
  • Next by Date: Re: Communicate with pipe and AuthorizationExecuteWithPrivileges
  • Previous by thread: Re: autoreleasing NSBezierPath object
  • Next by thread: Re: autoreleasing NSBezierPath object
  • Index(es):
    • Date
    • Thread