title: Core Data & Threads
body: <p>I'm working on an app that uses core data and I'm aware that this is not thread safe but struggling to understand how to manage this correctly. Let me explain what I have so far...</p>
  
  <p>I've created a singleton the initiates the managed object and is then available to all other classes, this appears to be working correctly as the same managed object address is received by all classes.</p>
  
  <p>I then have two clases that are executed in this order...</p>
  
  <ol>
  <li>Data load. This gets the record count and if zero loads the core data base.</li>
  <li>Tableview that then displays the data stored in step 1.</li>
  </ol>
  
  <p>My problem is that step 1. Is always returning zero records, and step 2. Is working and returns the correct record count.</p>
  
  <p>Having done some testing the problem with 1. Is due to the thread its running on, if I despatch the request on the same thread that the managed object was created on it works perfectly.</p>
  
  <p>So why is it in class 1. i have to ensure that the request is on the correct thread but in class 2. It just works, or is it just pure luck. Is there a recommended and documented approach to threads and core data?</p>
  
  <p>Thanks</p>