I am working on an app that fetches data from an API, turns that into Core Data Managed Object by first converting to a dictionary and finally iterating over every object and saving it synchronously from the main thread.
I am working with a large dataset so the number of objects could be in thousands, and this procedure works for the most part. But in some cases, say 1 in every 4 trial, the app crashes with the following error:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -_referenceData64 only defined for abstract class.
I have been trying to solve it for some time but with no luck. I am thinking it has something to do with the main thread and I tried saving it from a background thread but that didn't work either and as per the apple documentation, the context can only be referenced from the main thread.
I would really appreciate it you guys could help me out here. Thanks in advance to all of you.