Re: autorelease use...
Re: autorelease use...
- Subject: Re: autorelease use...
- From: "Tristan O'Tierney" <email@hidden>
- Date: Mon, 18 Jul 2005 14:28:56 -0400
i think you misunderstood the point of my example. the point was, if you
wanted the string to stick around PAST THE LENGTH of the function, you need
to retain it. it was just an arbitrary example, without me having to dive
into member variables, object dealloc methods that properly release the
variable, etc, etc, etc.
On 7/18/05, Charilaos Skiadas <email@hidden> wrote:
>
> On Jul 18, 2005, at 9:20 AM, Tristan O'Tierney wrote:
>
> - ( void ) myFunction {
>
> NSString *str = [NSString stringWithString: @"my string"];
>
> [str retain];
>
> }
>
>
> Unless I'm mistaken, this will leak, no? str is a local variable declared
> in the function, so it is lost the moment you exit the function, and the
> retained object sticks around forever. I am guessing what you meant was the
> same without NSString * in front, where it is assumed that str is an
> instance variable of the object in question?Or have I gotten it all wrong?
>
> To Luc: Joar's email really nailed the issue. You should think of memory
> management in terms of ownership. Should your object own the other object or
> not?
>
> Haris
>
>
>
--
Tristan O'Tierney
- Email: tristan [TA] otierney <DOT> net
- Homepage: http://www.otierney.net
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden