Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

In CoreData, how should I call context.save()?

In CoreData, what is the best approach for using context.save()? Should I call it when the object is added in the array or should I add all the objects together in the array and then call context.save()?

It is kind of confusing because I did not get accurate answer.

I have tried both I do not know what should be the proper approach.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Based on what I have understood reading your question is that the best approach in my opinion is to call context.save() once because calling it frequently can cause issues. Therefore, my suggestion is to add all the data in your array and then call context.save(). I hope this clears your confusion.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading