I'm importing ~18,000 records of various entities that are related to each other from a web service on first launch of an iOS app. The records have their own unique identifiers from the database on the web. I have read and re-read apple's documentation, cimgf's blog entries, Marcus Zarra's books on core data, and watched over and over again the iDeveloper TV's series on core data. I can't figure out a way to import Entity A without keeping Entity B, C, and D in memory or performing expensive fetches and maintain relationships between the entities. If I were not using core data, I'd be able to just use the unique identifiers that are already established and the import would be much faster.
If you have any suggestions, I'm all ears.
We've implemented this strategy in Android and the import takes ~2.5 minutes compared to ~6 minutes on iOS where the hardware on the different devices are comparable. Shortening the import time is crucial to our users so I have not been able to compromise on this issue. Thanks in advance for your help.
EDIT:
Here's how I'm currently doing it - I create an NSOperation which creates it's own context. I import Entities B, C, & D first and keep an array per entity type. I then import Entity A and use predicates to filter the arrays for Entities B, C, & D in order to relate Entity A to the appropriate Entities in B, C, & D. I'm batch saving the context at optimized intervals that are different depending on which entity type I'm currently importing.
I'm not just importing to one table, I'm importing many tables that are related to each other. So If I import Entity B, I have to either keep Entity B in memory or fetch it when I need it to relate Entity B to Entity A. Make sense?