开发者

How to remove duplicate entries in CoreData?

i am parsing an XML and saving the Data's to coreData. Parsing of XML works fine, saving too. Actually, wh开发者_StackOverflow中文版en i am parsing the XML again, the old entries will not be updated. AND it not deletes the old entrys.

Everytime i get more and more duplicate entries.

In my XML i have childelements with childelements, and the childelements of parentelement have UNIQUE ID's.

How can i solve this duplicate entry problem in CoreData?

I dont want to delete the hole coreData file before parsing XML, i want to check, if anything has changed and update the changes.


Are you saving the unique IDs? If not, then do so and you will then be able to test whether something already exists and whether it needs to be updated.

Core Data has a very different notion for a row ID than SQL. In CD's case, the object instance is the id. Relations are sets and you test whether objects are members of sets. Your challenge is to map your unique IDs onto CD objects. It isn't hard but it doesn't come for free.

Andrew

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜