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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:26:54+00:00 2026-05-26T04:26:54+00:00

I know, this is basic stuff. But I get confused about this all the

  • 0

I know, this is basic stuff. But I get confused about this all the time.

So let’s say I have a class called HolderClass with an NSString property called changeMe.

I have another class called PassedToClass, and it has a method that takes an instance of HolderClass as a parameter, and inside that method it uses that instance of HolderClass to set a property called holderInsideOtherClass.

I’m going to pass an instance of holderClass into an instance of PassedToClass like so:

HolderClass *demonstrationHolder= [HolderClass new];
PassedToClass *passToMe = [PassedToClass new];

demonstrationHolder.changeMe = @"FirstString";

[passToMe arbitraryMethodThatTakesAHolderClass: demonstrationHolder];

Now, after this is done, I can check the value of changeMe inside both classes:

NSLog (@"%@", demonstrationHolder.changeMe);
NSLog (@"%@", passToMe.holderInsideOtherClass.changeMe);

And both of those should print out “FirstString”.

But now, what happens if I do this:

[demonstrationHolder.changeMe = @"SecondString"];

NSLog (@"%@", demonstrationHolder.changeMe);
NSLog (@"%@", passToMe.holderInsideOtherClass.changeMe);

I know I should know this already, but can anybody help?

  • 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-26T04:26:54+00:00Added an answer on May 26, 2026 at 4:26 am

    Variables that hold objects are merely pointers (memory addresses). When you pass them around or assign them to other variables, you’re still referencing the exact same object at the exact same memory location.

    So when you pass demonstrationHolder into passToMe, passToMe simply gets a reference to the original object. If you change that particular object anywhere, those changes will show up for every piece of code that holds a reference to that particular object. It’s the same object.

    When dealing with objects that can change in this way (“mutable” objects), it is common to define properties as being copy rather than assign/retain/strong. When this is the case, and you assign an object to that property, instead of it simply storing a reference, a new object is created that is a copy of the original object, and a reference to the new object is stored instead. This means that any future changes to the original object will not affect the new copy.

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

Sidebar

Related Questions

I know this question might seem a little basic stuff but I want to
OK, this is probably pretty basic stuff, but it took me quite some time
I know basic stuff about UML: - Use Case - Activity Diagram - Class
I know this maybe a basic question but I just can't seem to find
I know this may be basic but I cannot seem to add a member
Know this might be rather basic, but I been trying to figure out how
I know this maybe a very basic question but I'm having a bit of
I know this should be a basic question but I am hitting a brick
I know this sounds confusing: I have just built some basic prev/next pagination for
guys I know this question is very basic but I've met in few publications

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.