Re: Newbie question regarding Learning Cocoa
Re: Newbie question regarding Learning Cocoa
- Subject: Re: Newbie question regarding Learning Cocoa
- From: John Hörnkvist <email@hidden>
- Date: Tue, 5 Jun 2001 18:16:34 +0200
On Tuesday, June 5, 2001, at 03:01 PM, Andreas Monitzer wrote:
On Monday, June 4, 2001, at 07:52 , Finlay Dobbie wrote:
@"Hello world" is actually an NSString object, which I think might be
autoreleased, I'm not sure..
It's not autoreleased, it's static. That means that it's part of the
code,
it exists in RAM as long as the class exists there. So don't call
retain,
release or autorelease on a static NSString.
You can certainly call retain/release on statically allocated NSString
objects.
This is just fine:
[[@"MyString" retain] release]
But in the case of using an autorelease pool around NSLog(@"Hello
world"), the worry is that NSLog will use autoreleased objects
internally.
Regards,
John Hornkvist
--
ToastedMarshmallow, the perfect Cocoa companion
http://www.toastedmarshmallow.com