Validation Errors

Before objects can be saved to a persistent store, they must pass validation. If an object fails validation, an NSError from the NSCocoaErrorDomain will be thrown. There are just over a dozen types of validation errors, which you can see by jumping to the definition of NSManagedObjectValidationError in Xcode. This jump will take you to CoreDataErrors.h, which defines the validation errors that are also shown in Table 4.1.

Image

Table 4.1 Possible Validation Errors

The application currently can’t save due to error 1600. A validateForDelete was put in place to at least ensure the save isn’t attempted. Because it’s likely this type ...

Get Learning Core Data for iOS: A Hands-On Guide to Building Core Data Applications now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.