Implement searching or creating flat file data during import

I am importing a large plist / XML into Core Data. The structure is simple: let's say there is a Man and a Company, and a Company can have many people. Import is successful, but plist does not have an established relationship, therefore, duplicate companies are inserted every time when several people have the same company.

A potential solution is the Apple Core Data Docs in the Effective Build or Build section:

Or, if you import β€œflat” data without any relationships, you can create managed objects for the entire set and filter out (delete) any duplicates before saving using one large IN predicate.

I looked at this sentence for a long time and I can not make it out. Didn't I use managed objects to import the whole set? What query query do they refer to?

An algorithm or explanation will be appreciated.

+3
source share
1 answer

In your example, it is best to do a company search / search during import so that you can set up relationships correctly. Depending on the size of your data, you might even want to store company objects in memory NSDictionaryso that you can easily attach them to human objects as you import them.

0
source

Source: https://habr.com/ru/post/1732237/


All Articles