title: How to prevent Core Data making duplicates in iOS 5?
body: <p>I've run into a problem.</p>
  
  <p>Over the weekend I've been working on a project where I'm pulling a large xml from a webservice.</p>
  
  <p>It basically has 3 tiers - Clients, Managers, Staff all hierarchical. So the first time the app runs, it pulls this xml and parses it and creates all the entries in the 3 releated Entities - Clients, Managers and Staff.</p>
  
  <p>Every time the app launches I need to pull that same XML down, but this time, I only need to 'update' any of the existing records that have changed, or add new ones for new clients, managers or staff that have appeared since last time.</p>
  
  <p>So - at the moment, as I said, it's pulling it all, parsing it correctly and creating the correct entities and filling in all the attributes.</p>
  
  <p>However, with no data change, on the 2nd launch it's DUPLICATING all of the data - so instead of 15 clients ( the correct number ) I have 30 and so on...</p>
  
  <p>Do I really have to add lots of code in my parsing to check that instead of creating a new NSManagedObject, I check if it's already there?</p>
  
  <p>And if it is - I have to then manually check every attribute?</p>
  
  <p>That's awfully painful and longwinded - isn't there a way to make Core Data do this kinda stuff for me - automatically?</p>
  
  <p>Thanks for any help or suggestions.</p>