• 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: -retain and -release Questions
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: -retain and -release Questions


  • Subject: Re: -retain and -release Questions
  • From: Cameron Hayne <email@hidden>
  • Date: Sun, 04 Apr 2004 22:14:25 -0500

On 3/7/04 2:20 AM, "Jerry Krinock" <email@hidden> wrote:

> Generally, if I create (-alloc and -init) an object for temporary use only
> within one method, I believe I need to -release this object before the
> method returns. This is in contrast to C++, where objects are automatically
> deleted when they go out of scope. Is this correct?

No - the situation is closer than you think.
Note that your Obj-C object variables hold pointers to the objects, not the
objects themselves. So the situation is analogous to calling 'new' to create
a temporary object - in that case the C++ object does not get deleted when
the (pointer) variable goes out of scope.

As to leak-detection utilities, there are some supplied by Apple as part of
the dev tools - look under /Developer/Applications.

--
Cameron Hayne (email@hidden)
Hayne of Tintagel
_______________________________________________
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: -retain and -release Questions
      • From: Prachi Gauriar <email@hidden>
  • Prev by Date: Re: Is the internet avaliable question
  • Next by Date: Re: Is the internet avaliable question
  • Previous by thread: [ANN] Graphviz 1.12 (v5) for Mac OS X
  • Next by thread: Re: -retain and -release Questions
  • Index(es):
    • Date
    • Thread