In my iPhone app I provide users with a view of industry news items. I get this list as an xml file from my server. Parsing and inserting the xml data into my Core Data repository is a no brainer, but there are a few cases where I might get duplicate news item entries.
I thought a good solution would be to insert all the updates when I process the xml feed and then remove any duplicates. But I can’t figure out how to do the latter. How does one remove duplicate objects in Apple’s Core Data framework?
To make this concrete, let’s say I have a news item:
News Item - uniqueId (set by the external system) - title - newsText
Is there any succinct way to tell Core Data to just delete duplicate objects, where a duplicate object is defined as an object with the same “uniqueId”? I.e., without doing an explicit fetch in my code and making sure not to insert the object if an object witht he same “uniqueId” already exists?
Thanks for any suggestions.