• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: "Constant" strings are static or autoreleased?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Prev by Date: Re: "Constant" strings are static or autoreleased?
  • Next by Date: Re: ControlElements (was re:OutlineView)
  • Previous by thread: Re: Solutions for the shfiting sheet bug?
  • Next by thread: NSPopUpButton won't display its button title dimmed?!!
  • Index(es):
    • Date
    • Thread