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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T17:47:32+00:00 2026-06-15T17:47:32+00:00

I am trying to create a mutable array in objetive c to hold references

  • 0

I am trying to create a mutable array in objetive c to hold references to objects. The objects in the array are regularly updated through user interaction and i want the array to automatically reflect changes made to the objects as they occur. Does anyone know if there is a way to do this? Perhaps store pointers to the objects instead of the objects themselves in the array? Any help would be much appreciated

Thanks in advance

Edit: I should mention that the objects are not exactly being updated in the strict sense of the word. They are being reinitialized. For ex if i had a controller:

MyController = [MyController alloc] initWith…..]]

the above call is made again with different init parameters.

  • 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-15T17:47:33+00:00Added an answer on June 15, 2026 at 5:47 pm

    The array always stores the pointers…. It holds a strong reference to it or sends it a retain message (if using non ARC).

    So

    [myMutableArray addObject: anObject];
    

    adds the pointer to it.

    If you now change anObject’s properties and access it later through the array, it will
    give you the pointer to just that object with the changes to its properties.

    Edit:

    No, if you alloc/init, you are creating a new object instance and allocate new memory for it on the heap (ie, it’s another pointer to a new memory address).
    What exactly are you trying to accomplish? There sure is a way, if you provide a little more detail.

    If you alloc/init the object with the same class, why not just create a method to change the object’s properties:

    Instead of

    myObject = [[MyClass alloc] initWithParameter1: one parameter2: two];
    

    You could create a method that changes these properties:

    [myObject updateParameter1: anotherOne parameterTwo: anotherTwo];
    

    And, of course, the advantage of a mutable array is, that you can change its contents, so like @Eli Gregory pointed out, you can replace an object with another one (or rather the pointers to it).

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

Sidebar

Related Questions

I'm trying to replace a dictionary in a mutable array. Steps 1 through 4
I'm trying to create a mutable Map with a default that creates a new
Possible Duplicate: “Least Astonishment” in Python: The Mutable Default Argument I'm trying to create
I'm trying create a bot which automatically likes Facebook posts. Using Mechanize I can
I am trying a simple application where I have a mutable array of mutable
So my problem is basically this, I'm parsing through a mutable array of numbers
I am trying to create a model for Catalyst by using DBIx::Class::Schema::Loader. I want
i am trying to save a mutable array into a file with the help
I am trying to push a mutable array into the UITableView.But my UITableView doesn't
I am new to objective-c and I am trying to create an array of

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.