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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T00:19:24+00:00 2026-06-06T00:19:24+00:00

I am confused between NSString and NSMutable string usage. Suppose I have instance variables

  • 0

I am confused between NSString and NSMutable string usage.
Suppose I have instance variables one and two declared in class like this:

NSString *one;
NSMutableString *two;

let us suppose I have created setters and getters of them using properties.

lets say I have changed my “two” string like these:

     1. [two appendString:@"more string"];
     2. two = @"string"
     3. self.two = @"string"

Questions:

  1. would 1st line release previous string and allocate new object and assign value to it.
    if yes, then does that mean creating getters and setters are unnecessary in this case ? OR its unnecessary to create properties in NSMutablestring

  2. In this case would the previous allocated string object released ?

  3. Its for sure that first object would be released as we are calling setters here. is this code necessary or we can just use the code line 2 to assign string.

Now about NSString:
As can modify the string like this also :

    one = [one stringByAppendingString:@" more string"];
    self.one = [one stringByAppendingString:@" more string"];

Which is better using NSMutablestring or NSString ?

Sorry for long post, but I needed to understand these concepts.

  • 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-06T00:19:25+00:00Added an answer on June 6, 2026 at 12:19 am

    For the first part of your question:

    1. Almost definitely not. I expect the memory will be allocated dynamically, rather than released and reallocated.

    2. If the previous answer is no, this is also, no.

    3. The second and third options don’t even work with the warning Incompatible pointer types assigning NSMutableString to NSString

    I expect NSMutableString will be slightly more efficient in terms of memory as you are indicating early on that the program may need memory dynamically. NSString is likely to be allocated a single, suitably sized block of memory.

    Your views of NSMutableString seem to be what the stringBy.. methods of NSString will do:

    With NSString and its stringBy... methods, you are creating new objects, releasing the old one (if need be) and making the new object autorelease. (Take care if you are changing from non-autorelease to autorelease, you may have a release in your dealloc that isn’t needed anymore)

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

Sidebar

Related Questions

I am very much confused between instance variables and property. I have read number
I have a class called FileProc that runs File IO operations. In one instance
I am totally confused between WCF and ASMX web services. I have used a
I'm a little confused between the two. As per I know both returns hibernate
I am very confused between these two consistency models. Please give some timeline examples
I am confused between these two functions: void Swap_byPointer1(int *x, int *y){ int *temp=new
I'm so confused between the text to speech technologies in Windows. I have a
I'm quite confused between those two. I'm looking at the Play! java framework and
I have two images. The first one is of background noise + content, and
I am some what confused as to the difference between accessing an instance variable

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.