[Top][All Lists]

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

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

From: Adam Fedor
Subject: Re: does NSLog take ownership of the NSString it is given?
Date: Sun, 15 Jun 2003 20:30:48 -0600

On Sunday, June 15, 2003, at 12:35 PM, Dan Hitt wrote:

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

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...

Autorelease pools are created in the application run loop. So if you are doing things within an application, temporary objects get freed every event cycle (basically every time there is an event).

The one created in main() is just a 'cleanup pool' that takes care that everything is freed. In many tools, for instance, there is no run loop so temporary objects don't get freed until the end when the autorelease pool is freed.

Look in -[NSApplication run]

reply via email to

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