Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8303973
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T17:41:10+00:00 2026-06-08T17:41:10+00:00

Possible Duplicate: NSString allocation and initializing I was wondering why some objects don’t need

  • 0

Possible Duplicate:
NSString allocation and initializing

I was wondering why some objects don’t need to be initialized and have memory allocated. I read this: Why do some objects not need to be initialized before use in objective-c? And they said that the method date initialized and allocated memory for today. But if I just wrote NSString *str = @"Hello"; does it still initialized and allocated?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T17:41:12+00:00Added an answer on June 8, 2026 at 5:41 pm

    When the compiler sees @"Hello", it sticks a symbol in the .o file that says “hey, dev wants a string with contents "Hello". When the linker links together everything, it unique-ifies all the strings and emits a string table that contains all the strings that the code defined within.

    So, in effect, the compiler is “allocating and initializing” the string instances at compile and link time.

    They are actually stored in a special format that a particular subclass of the NSString class cluster can encapsulate. When your app is run, the instances of this subclass already exist and are simply mapped into memory.

    So, no, not allocated and initialized. But, yes, still objects in every sense of the word. The only caveat is that they ignore retain/release/autorelease and, thus, when you do NSString* foo = @"foo";, technically that should also be retained. But, by convention, no one ever bothers and that’s just fine.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Convert NSString of a date to an NSDate I need some help
Possible Duplicate: NSString @property, using copy instead of retain I have a basic memory
Possible Duplicate: NSString stringWithFormat adding a percent a noob question here. I have a
Possible Duplicate: Convert from char* to NSString? I have char myChar = 'r' How
Possible Duplicate: Send NSString via Game Center i have been working on this for
Possible Duplicate: Do I need to release NSString generated using @“…”? There are two
Possible Duplicate: Convert UTF-8 encoded NSData to NSString I need to to convert the
Possible Duplicate: Convert NSArray to NSString in Objective-C I have an array of an
Possible Duplicate: Most memory efficient way to split an NSString in to substrings I'm
Possible Duplicate: NSString: newline escape in plist I have a plist with a string,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.