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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T06:43:46+00:00 2026-05-11T06:43:46+00:00

My iPhone client has a lot of involvement with asynchronous requests, a lot of

  • 0

My iPhone client has a lot of involvement with asynchronous requests, a lot of the time consistently modifying static collections of dictionaries or arrays. As a result, it’s common for me to see larger data structures which take longer to retrieve from a server with the following errors:

*** Terminating app due to uncaught exception 'NSGenericException', reason: '*** Collection <NSCFArray: 0x3777c0> was mutated while being enumerated.' 

This typically means that two requests to the server come back with data which are trying to modify the same collection. What I’m looking for is a tutorial/example/understanding of how to properly structure my code to avoid this detrimental error. I do believe the correct answer is mutexes, but I’ve never personally used them yet.

This is the result of making asynchronous HTTP requests with NSURLConnection and then using NSNotification Center as a means of delegation once requests are complete. When firing off requests that mutate the same collection sets, we get these collisions.

  • 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. 2026-05-11T06:43:47+00:00Added an answer on May 11, 2026 at 6:43 am

    If it’s possible that any data (including classes) will be accessed from two threads simultaneously you must take steps to keep these synchronized.

    Fortunately Objective-C makes it ridiculously easy to do this using the synchronized keyword. This keywords takes as an argument any Objective-C object. Any other threads that specify the same object in a synchronized section will halt until the first finishes.

    -(void) doSomethingWith:(NSArray*)someArray  {         // the synchronized keyword prevents two threads ever using the same variable     @synchronized(someArray)     {        // modify array     }  } 

    If you need to protect more than just one variable you should consider using a semaphore that represents access to that set of data.

    // Get the semaphore. id groupSemaphore = [Group semaphore];  @synchronized(groupSemaphore)  {     // Critical group code. } 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We've been programming an iPhone application under iPhone OS 3.1, but the client has
We are developing an application that has an iPhone client, and a Rails server.
I've written an iPhone application for a client. He has purchased a single developer
I am sending data between Java and iPhone/objC clients. The Java client has an
My client has saved lot of Google Adsense javascripts in his db and displaying
I am tasked to provide an IPhone client app for our SaaS website. I
I am writing an iPhone app – a client for some social network. The
I have multiple but similar client-side iPhone apps, managed as branches in git (all
i am using Twisted python for sending reply to my client app (iPhone app).
My client can't read iPhone's default fonts, the size is too small. I have

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.