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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T20:47:35+00:00 2026-06-17T20:47:35+00:00

I was trying to understand dereferencing in Objective-C and wrote below two methods. -(void)alterStringModelOne:(NSMutableString**)string{

  • 0

I was trying to understand dereferencing in Objective-C and wrote below two methods.

-(void)alterStringModelOne:(NSMutableString**)string{
    NSMutableString *str = [NSMutableString stringWithString:@"New string by string = &str"];

    string = &str; //Didn't work
}
-(void)alterStringModelTwo:(NSMutableString**)string{
    NSMutableString *str = [NSMutableString stringWithString:@"New string by *string = str"];

    *string = str; //It works
}

In above, ModelOne didn’t work while ModelTwo does. How are these two statements different?

Edit: Tracing their address and type

myStr = b260 of type * CFString

—> Enters method model one

string = d9c4 of type ** NSMutableString //Parameter

str = f750 of * CFString //after str creation

string = d97c of type ** NSMutableString //After assignment: string = &str;

–> method returns

myStr = b260 * CFString

–> Enters method model two

string = d9c4 of type ** NSMutableString //Parameter

str = 0bc0 of * CFString //after str creation

string = 0bc0 of type * CFString //After assignment: *string = str;

–> Leaves method

myStr = 0bc0 of type * CFString

  • 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-17T20:47:36+00:00Added an answer on June 17, 2026 at 8:47 pm

    First of all: This is not specific to Objective-C. The same behavior exists in C and C++.

    string = &str;
    

    This modifies the value of the local variable string.

    *string = str;
    

    This modifies the value pointed to by string.

    Since string is a local variable, changing it (as seen in the first example) does not have any lasting effect. The value it points to is not local, though, so changing that (second example) does do what you want.

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

Sidebar

Related Questions

I am relatively new java. I am trying understand what are the usage of
trying to understand methods and virtual function lets say i have 3 classes (the
Trying to understand the new async/await pattern, I have one question which I can't
I am trying understand why one of my printf statements fail. #1 below is
Trying to understand how the code below always brings up a number between 0-6
just trying to understand this code. $db = new DB(DB_DRIVER, DB_HOSTNAME, DB_USERNAME, DB_PASSWORD, DB_DATABASE);
I am trying to understand how pointer incrementing and dereferencing go together, and I
Trying to understand when implementation of IDisposable is necessary: I wrote a little example.
I am trying understand ViewModels deeper and I have read many articles and blogs
Trying to understand what's the correct way of implementing OpenID authentication with Spring Security.

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.