Re: "Constant" strings are static or autoreleased?
Re: "Constant" strings are static or autoreleased?
- Subject: Re: "Constant" strings are static or autoreleased?
- From: marquis logan <email@hidden>
- Date: Wed, 05 Mar 2003 13:02:15 -0800
>
>On Wednesday, March 5, 2003, at 03:23 PM, sinclair44 wrote:
>
>NSString *myString = @"string";
>
>Is the same as
>
>NSString *myString = [NSString stringWithCString:"string"];
@"string" is not autoreleased. it's stored in the text segment of the binary and can't be released. it's of type "NSConstantString" and never goes away (they override dealloc or retain/release or something). iirc the compiler ensures that there are no duplicates.
"string" is a constant c-string and is also stored in the text segment of the binary.
NSString *myString = [NSString stringWithCString: "string"];
is n dynamically allocated, autoreleased, immutable NSString like you described. and can and is destroyed. every @"string" is the same, while every [NSString stringWithCString: "string"] is unique.
nibs
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.