title: iPhone use of mutexes with asynchronous URL requests
body: <p>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:</p>
  
  <pre><code>*** Terminating app due to uncaught exception 'NSGenericException', reason: '*** Collection &lt;NSCFArray: 0x3777c0&gt; was mutated while being enumerated.'
  </code></pre>
  
  <p>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.</p>
  
  <p>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.</p>