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: Richard Frith-Macdonald
Subject: Re: does NSLog take ownership of the NSString it is given?
Date: Mon, 16 Jun 2003 08:01:30 +0100


On Sunday, June 15, 2003, at 07:35  pm, Dan Hitt wrote:

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.

The autorelease pool in main() is used as a catchall ... to ensure that
objects not created in other pools last for the lifetime of the program.

The autorelease pools are not normally used directly, instead the
-autorelease method (which all objects inherit from NSObject) is
generally called.  This method adds the receiver to the newest
autorelease pool in the executing thread.

May methods create and destroy autorelease pools, so that any
temporary objects they create are destroyed before they return.

You can do the same in your own code.





reply via email to

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