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 1102735
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T01:13:54+00:00 2026-05-17T01:13:54+00:00

For NSString, we can use NSString *str = [[NSString alloc] initWithString:@hi] NSString *str =

  • 0

For NSString, we can use

  1. NSString *str = [[NSString alloc] initWithString:@”hi”]

  2. NSString *str = [NSString stringWithString:@”hi”];

  3. NSString *str = @”hi”;

Can someone pls told me in the form of point 3, whether str own @”hi”? I mean whether I need to [str release] when clean up?

Thanks

for point 1, yes, I need; for point 2, no, I don’t

For point 3?

  • 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-05-17T01:13:55+00:00Added an answer on May 17, 2026 at 1:13 am

    No, you don’t need to release it.

    String literal (that’s what you have in case 3) are created in compile time and their lifetime is the lifetime of your application. You can also easily check that release/retain operations do not affect their retain count (try to NSLog retainCount property and you’ll see that)

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

Sidebar

Related Questions

NSString *str = [[NSString alloc]init]; str = [str initWithString:@]; This code crashes. If I
When reading an NSString from a file I can use initWithContentsOfFile:usedEncoding:error: and it will
How can I check if an NSString contains another substring, at which point it
Can someone explain the difference between static NSString* CellIdentifier = @Cell; and NSString *CellIdentifier
Is there a simple way to escape a NSString so I can use it
I need that I can use 1 object of NSString to use in all
I know you can use NSBundle: NSString *filePath = [[NSBundle mainBundle] pathForResource:@foo ofType:@rtf]; to
I need to get the contents from this URL http://google.fr/ok in a NSString can
Simple case of trying to prove I can convert NSString to NSDate . Create
how can i convert NSURLRequest to NSString ?

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.