Re: copy and release
Re: copy and release
- Subject: Re: copy and release
- From: "David P. Henderson" <email@hidden>
- Date: Thu, 2 Aug 2001 23:16:57 -0400
On Thursday, August 2, 2001, at 09:40 , Michael Horn wrote:
>
When you copy an object. Eg,
>
>
stringB = [stringA copy];
>
>
Does this automatically autorelease stringB or is this just like doing
>
>
stringB = [[NSString alloc] initWithString: stringA];
>
>
?
>
-copy does not return an autoreleased object. -copy returns a copy of
the object with a retain count of 1, BUT in the case of immutable
objects and -copy if the object being copied is immutable -copy will do
[stringA retain] instead of copying the object if stringA is an
immutable string. So to answer your question: No copy does not return an
autoreleased object, and Yes in most cases -copy is similiar to the
second assignment statement.
Dave
--
Chaos Assembly Werks
"Suburbia is where the developer bulldozes out the trees, then names the
streets after them."
- Bill Vaughn