Our app has lots of raw data points which we fetch from our server and save in core data.
App performs numerous operations on this raw data to show desired result to the user.
To achieve this, we save this raw data into our core data entities.
Complete process looks something like this:
API Response
persistentContainer.newBackgroundContext() //in the same background queue
context.perform {
create NSManagedObject
context.save()
}
Now multiple APIs go in parallel for all kind of objects and all of them follow this same process.
Multiple APIs for same object also go in parallel. I sense an issue in this case.
Let’s say app receives 3 API responses in parallel for a particular object. That mean there will 3 background contexts created which will try to edit the same Entity.
1- Could this lead to a crash?
2- Is there a better way to handle it?