Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using the new Core Data Batch Updates, is it possible to batch delete?

Tags:

ios8

core-data

My current method of deleting all of a certain kind of object in Core Data is to iterate over each object and delete manually, which is rather expensive.

Using the new batch updates added to Core Data this year, can it be accomplished like that?

like image 204
Doug Smith Avatar asked Oct 03 '14 19:10

Doug Smith


People also ask

How do I delete data from Core Data?

For saving the data, first, we take manage object context that provides us a method called “delete object”. To delete an object from the database we use the “delete object” function. we need to call the “save” method to commit the change. we also remove the record from the table view.

What is the meaning of batch delete?

Deleting a batch means deleting all the test results in that batch. It does not impact the baselines related to the test results in any way.

What class would you use to filter fetched results from Core Data?

You can use . filter on the fetchedResults. Yes you can, but that's a Swift function. Using NSDelegate delegates filtering to Core Data which can be more efficient, especially on large data sets.


Video Answer


1 Answers

Unfortunately it's not possible at this time in OS X 10.10/iOS 8.

An NSBatchUpdateRequestis only limited to update selected properties. More information on this can be found in this blog post (see the "Deleting a lot of Objects: Not a Problem" section).

like image 175
flashfabrixx Avatar answered Nov 17 '22 01:11

flashfabrixx