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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T23:56:17+00:00 2026-06-13T23:56:17+00:00

I am trying to understand something that i thought i know. if in class

  • 0

I am trying to understand something that i thought i know.

if in class A i do :

-(NSMutableArray*)setArray:(NSMutableArray*) array1
{
//some calculations on array 1
  return array1.
}

than in classB i :

 ClassA *instanceA = [[ClassA alloc]init] ;
 ClassC *instanceC = [[ClassC alloc]init] ;
 [instanceC sendArray:[instanceA setArray:someArray] ]; //some array allocated in b
 [instanceA release];
 //in ClassC i have defined  arrayC ,that gets array as a pointer from classB

Is array1 stay valid in ClassC after i released instanceA ?

Does every change made to the array in ClassB is also made to the arrayC ?

Is this the right way to work ? my goal is to control over the arrayC in ClassC so every change i do in ClassB will apply to the one in C also, AND to not lose this relation because of some autorelease.

Doing this with property will be better ? how ?

thanks.

  • 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-13T23:56:18+00:00Added an answer on June 13, 2026 at 11:56 pm

    The question is a bit unclear, so I’m guessing somewhat at what you’re trying to understand.

    You ask “Does every change made to the array in ClassB is also made to the arrayC ?”

    The answer is that neither class B or class C have an array, rather they both have a reference to an array. Now if both class B and class C hold the same reference, then a change via that reference in class B is visible in class C via it’s reference – as they are both referring to the same array. Copying references does not copy the array, create a new array, or anything like that, it just copies the reference.

    If that is still confusing think of an array reference as the address of a house. You can write the address of the house down on as many pieces of paper as you like and pass them to as many people as you like, and if each person reads the paper and goes to the address they all end up at the same house. If one of those people break a window in the house all the other people see the broken window – there is only one house.

    HTH and I’m not answering the completely wrong question!

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

Sidebar

Related Questions

I'm trying to understand something that , by googling around, seems like a bug
Trying to understand something. I created a d:\svn\repository on my server. I committed folders
I'm trying to understand on a deeper level if I'm missing something as to
I am trying to understand the difference between this: if (isset($_POST['Submit'])) { //do something
I'm trying to understand REST. Under REST a GET must not trigger something transactional
I'm trying to learn MVVM, but there is something I don't understand yet. Currently,
I'm not a PHP programmer (but know other languages), and I'm trying to understand
I know that new-ing something in one module and delete-ing it in another can
I have been trying for some time to determine why the Object class has
I am trying understand ViewModels deeper and I have read many articles and blogs

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.