• 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: NSBezierPath retain crash
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSBezierPath retain crash


  • Subject: Re: NSBezierPath retain crash
  • From: Christopher Corbell <email@hidden>
  • Date: Wed, 12 Nov 2003 10:43:16 -0800

On Nov 12, 2003, at 10:02 AM, Chad Harrison wrote:

I have an object which includes one instance of a NSBezierPath, but when I try to do anything with the path (like transform or stroke), it crashes - I though that since I am creating it with bezierPathWithRect: rect, it was autoreleased and I did not have to retain it. Even if I specifically retain and release it, it crashes. I'm missing something here.

Review the Cocoa memory management docs again - autoreleased means
that the object is valid for the current call stack, but at any
time after the current stack returns the object may be
released from memory.

If you alloc, copy, or retain an object, it is not auto-released
and you can stash it away e.g. in a class member variable, and
release it when you're done.

If you use a method like bezierPathWithRect, stringWithCString, etc.
or otherwise obtain an autoreleased object, and want to use that
object persistently as a class member, you -must- call retain on the
object. (And then you're responsible for calling release or
autorelease on the object when you're done with it, e.g. you
replace it or the owning class is dealloc'd).

hth,
Christopher


=============================
Cider Factory Software, Inc.
http://www.cidersoftware.com
=============================
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: NSBezierPath retain crash
      • From: Chad Harrison <email@hidden>
References: 
 >NSBezierPath retain crash (From: Chad Harrison <email@hidden>)

  • Prev by Date: NSBezierPath retain crash
  • Next by Date: Re: NSBezierPath retain crash
  • Previous by thread: NSBezierPath retain crash
  • Next by thread: Re: NSBezierPath retain crash
  • Index(es):
    • Date
    • Thread