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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:30:06+00:00 2026-05-28T01:30:06+00:00

I kinda stumbled into the error where you try to remove objects from an

  • 0

I kinda stumbled into the error where you try to remove objects from an NSMutableArray while other objects is being added to it elsewhere. To keep it simple, i have no clue on how to fix it. Here is what i’m doing:

I have 4 timers calling 4 different methods that adds an object to the same array. Now, when i press a certain button, i need to remove all objects in the array (or at least some). So i tried to first invalidate all the 4 timers, and then do the work i want with the array, and then fire up the timers. I thought this would’ve worked since i am not using the timers anymore to enumerate through the array, but seemingly it doesn’t work.

Any suggestions here?

  • 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-28T01:30:07+00:00Added an answer on May 28, 2026 at 1:30 am

    It’s nothing to do with your timers. Because (I assume) your timers are all working on the same thread as your modifying method you don’t need to stop and start them. iOS doesn’t use an interrupt model for timer callbacks, they have to wait their turn just like any other event 🙂

    You’re probably doing something like

    for (id object in myArray)
       if (someCondition)
           [myArray removeObject:object];
    

    You can’t edit a mutable array while you’re going through it so you need to make a temporary array to hold the things you want to remove

    // Find the things to remove
    NSMutableArray *toDelete = [NSMutableArray array];
    for (id object in myArray)
       if (someCondition)
           [toDelete addObject:object];
    
    // Remove them
    [myArray removeObjectsInArray:toDelete];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Kinda hard to explain, but i'll try. I have a datalist that is populated
I stumbled upon this code: static void Main() { typeof(string).GetField(Empty).SetValue(null, evil);//from DailyWTF Console.WriteLine(String.Empty);//check //how
I'm kinda new to rails (3) and I stumbled upon a small... doorstep. Does
I stumbled upon a documentation where COM objects have two kinds of interfaces, one
I'm trying to remove some logging dependencies and stumbled across Castle Windsor's logging facility.
I am new to generics in C# and while reading a book stumbled upon
Kinda long title, but anyways... I've been looking at these examples, specifically on the
Kinda stuck here... I have an application with lets say 5000 rows of data
i kinda know how to create a Custom Web Part. But now i need
Title kinda says it all. The usual SOS command !bpmd doesn't do a lot

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.