Use NSPersistentContainer viewContext to save to disk?

703 views Asked by At

Is it safe to use the viewContext to save into the persistent store if I have large amounts of data? For example, I have 1000 records on my temporary background context which is a child of the viewContext of the NSPersistentContainer. Once I am done saving all 1000 records in the bg context, I want to save it using the viewContext to persist on the database. Is this the right approach or I should create a background context for saving to the persistent store?

1

There are 1 answers

0
Abizern On

Generally, I would use a background context for saving large amounts of data and let the main context pick up the changes from the persistent store.

I try use the main context as a read only context as much as possible in apps and use background or child contexts for saving and editing.