Transaction / Commit in Core Data, is it possible?

2

Is there a concept of Transaction and Commit in Core Data?

I have a base in the app that is fed by an external file, however there are a lot of data and the application takes around 2 minutes to perform this import so I need to run it in the background.

Is there a way to start a Transaction when I start importing (delete all old data and insert new ones) and commit when finished?

As you can use the app while the import is being performed, it is possible that access to some data has been deleted and this crashes the app (so I need to perform in a transaction).

An alternative that I thought is to create a database cache in case it is not possible to do Transaction and Commit.

    
asked by anonymous 18.08.2015 / 23:04

1 answer

1

There's no such thing in Core Data.

When you fetch the data and turn it into objects, even after making changes to those objects, you're not necessarily saving them. Only data insertion / editing is done, if called the save method of the core data. This is because all of these objects are only in the application memory and are only returned to the base using the -save method of the core data.

    
21.08.2015 / 18:31