Re: Memory allocation issues with NSObject and NSString
Re: Memory allocation issues with NSObject and NSString
- Subject: Re: Memory allocation issues with NSObject and NSString
- From: Chris Suter <email@hidden>
- Date: Mon, 19 Jan 2009 15:52:32 +1100
Hi Bill,
On Mon, Jan 19, 2009 at 3:21 PM, Bill Bumgarner <email@hidden> wrote:
> foo = @""; // foo is a reference to the empty string
> foo = [[NSString alloc] init]; // foo is a reference to the empty string
>
> The second is retained. The first is not. The first is a constant string
> and, thus, -retain/-release is a no-op. An implementation detail to ignore:
>
> foo = [@"" retain];
Are you sure about that? My understanding is that the second case ends
up pointing to a constant string and that retain and release are also
no-ops in that case.
Also, if I remember rightly, that in the first case you'll end up
pointing to a constant in the current translation unit, whereas in the
second case you end up pointing to a global constant defined in
CoreFoundation. Implementation details, I know.
Regards,
Chris
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden