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

  • SEARCH
  • Home
  • 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 6039209
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T06:20:07+00:00 2026-05-23T06:20:07+00:00

For non-retained string declarations, are these three lines the same? NSString *list2 = self.map;

  • 0

For non-retained string declarations, are these three lines the same?

NSString *list2 = self.map;

NSString *list2 = [NSString stringWithFormat:@"%@", self.map];

NSString *list2 = [NSString stringWithString:self.map];

They all create an autoreleased string object, right? Is there a preferred method among these, or are there any differences in the memory usage or behavior of “list2” depending on these methods?

For some reason, I find the manipulation of strings in objective-C the most confusing transition from other languages.

  • 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-23T06:20:08+00:00Added an answer on May 23, 2026 at 6:20 am

    They all create an autoreleased string object, right?

    No, the first one merely assigns the pointer returned by string.map to list2. The second and third ones theoretically create new NSStrings that you don’t own and assign them to list2. However, if string.map returns an immutable string, the third one will probably give you the same pointer (possibly retained and autoreleased).

    In all cases you do not own the (new) string. That’s actually all you need to know. They may be autoreleased, but it is not relevant to you using them.

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

Sidebar

Related Questions

I want sed to omit all non-matching lines, and only output the replaced string
In non-ARC code retained properties handily take care of memory management for you using
Non inline function defined in header file with guards #if !defined(HEADER_RANDOM_H) #define HEADER_RANDOM_H void
By non-instance types I mean types which do not expose a public constructor, for
For non-ASCII characters in file names, Git will output them in octal notation .
Custom non-fatal exception derive from which class in asp.net 3.5?
hobbyist/non-profession programmer here. I don't have a strong grasp on network addressing. I have
Grepping non printable characters doesn't seem to work for carriage return (control key ^M).
Using non-thread safe libraries with threads. Say I have a library that makes a
Coming from a non-Java background, I find myself writing a lot of View classes

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.