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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T12:29:17+00:00 2026-05-16T12:29:17+00:00

I decided to start using removeAllObjects so that I could re-use some of my

  • 0

I decided to start using removeAllObjects so that I could re-use some of my NSMutableArrays. However, I am finding that the call to removeAllObjects causes the array to get released and so it crashes when the viewController is displayed for the second time.

I’ve looked on the web and it seems that some people are saying that removeAllObjects just clears their array, while others are saying that it also releases the array. Which is true? It appears to release for me, but I find that weird and would expect the behaviour to be just to release the objects within the array. Nothing in the documentation warns of this, which I also find strange.

EDIT: With NSZombies turned on, all I get back is:

  • -[__NSArrayM removeAllObjects]: message sent to deallocated instance 0x625e4e0

Basically telling me that because the array was released due to the removeAllObjects, it can’t call removeAllObjects second time round… Argh!

Can anyone help please?

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-05-16T12:29:18+00:00Added an answer on May 16, 2026 at 12:29 pm

    Okay so I was being an idiot!

    I was doing:

    [myArray removeAllObjects];
    myArray = someOtherObject.someArray;
    

    therefore resetting the pointer to some other object. I’ve now changed it to this:

    [self.myArray removeAllObjects];
    [self.myArray addObjectsFromArray:someOtherObject.someArray];
    

    And it’s now okay. I’m an idiot! Sorry all, thanks for your help!

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

Sidebar

Related Questions

I have decided to start using unit testing in PL/SQL, since it could be
I've recently decided to start using some light unit testing to see if it
I just found out that Google recently decided to start using their own title
So I decided to start using prototype and here's my first question. I'm trying
Over the weekend, for some reason, one of our servers has decided to start
So for the summer I decided that I may as well start learning algorithms
I have decided to start doing small coding projects on my own that focus
I decided to start using HAML to speed up development, so, I decided to
When I decided to start using php framework, I have gone for CodeIgniter because
OK so I decided to start using interfaces in my code base and this

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.