-4

I usually write managedObjectContext().save(nil).

I think most of the cases you do not need a bulletproof, 100% code coverage, even apple engineers said in 2014 CloudKit lecture that error handling in Core Data is a good if have but not crucial feature, compare i.e. to CloudKit, where it is really important to deal with returned errors.

I would be curious at what cases is it worth to deal with error in Core-Data and how do you deal with it? Only plot error out to terminal? Send error reports to backend?

János
  • 32,867
  • 38
  • 193
  • 353

1 Answers1

4

Saving the context can fail. If you pass nil for the error parameter, you will lose information on what has gone wrong.

Failure while saving context can have severe consequences, for example, a user can loss his or her data. You may want to log information about such an event if it happens in production (and in a sufficiently complex application it is not unlikely to happen). Without knowing what the error was, it would be virtually impossible to debug.

Michał Ciuba
  • 7,876
  • 2
  • 33
  • 59