0

Is iterating over the array and deleting each one (as shown in Delete/Reset all entries in Core Data?) really the only way? Or is there a one-line method?

It's not that I don't want to type it, it's more of a performance concern in that I'd like to do it as efficiently as possible.

Community
  • 1
  • 1
Doug Smith
  • 29,668
  • 57
  • 204
  • 388
  • 1
    Wanna show us your code so we can help fix it? – kushyar Jun 09 '13 at 00:27
  • The deletion of managed objects is not inefficient - they are just marked for deletion. It is only when the context is saved that the SQL is executed to actually delete them (assuming you are storing them using sqlite). Since you have no control over the SQL generated you cannot control its efficiency. – Michael Jun 09 '13 at 12:53

1 Answers1

2

You have to loop over your array of managed objects and delete them one by one. Core Data provides no batch delete operation. Note that when you send the deleteObject: message to your managed object context the object will be marked for deletion. The actual delete is performed when the context is saved.

Sven
  • 22,475
  • 4
  • 52
  • 71