help-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: does NSLog take ownership of the NSString it is given?


From: Dan Hitt
Subject: Re: does NSLog take ownership of the NSString it is given?
Date: 15 Jun 2003 14:35:44 -0400

To follow up on my own post here:

Richard: thanks again for your kind help, which i really appreciate.

I was terribly remiss in not looking at NSString.h before posting.

The comments in that file naturally back you up: if i want to RELEASE
the string myself, i can just use one of the -init... methods (such as
-initWithFormat:)

I'm still unclear about when temporary strings get free'd (other
than when the pool they come from gets free'd), and i'd appreciate
any pointers from anybody on just what the connection is between
the autorelease pool one creates in main() and its eventual usage
(and how it gets passed around), but for now i can just use alloc/init...
code.

Thanks again to everybody who has helped me, and everybody who is
putting together this gnustep creation.

dan

-------------------------------------------------------------------------------
In article <bchihr$4jh$1@panix2.panix.com>, Dan Hitt <hitt@panix.com> wrote:
>Hi Richard,
>
>Thanks very much for your reply, which to summarize for reference
>is that a NSString returned by the class method +stringWithFormat:
>is owned by an autorelease pool (not me, so i can't free it).

.......

>In article <mailman.7915.1055650833.21513.help-gnustep@gnu.org>,
>Richard Frith-Macdonald  <richard@brainstorm.co.uk> wrote:
>>
>>On Sunday, June 15, 2003, at 12:37  am, Dan Hitt wrote:
>>
.......

>>Yes ... there are a few normal ways to create such objects that will be
>>owned by you ... using +alloc...., +new... or -copy.... and 
>>-mutableCopy...
>>Methods with other names return objects that you don't own.
>>
.......
>>
>>When the NSAutoreleasePool object which owns the temporary
>>string is destroyed, the string is also destroyed (unless something
>>else has retained it).


reply via email to

[Prev in Thread] Current Thread [Next in Thread]