1

From the docs:

If you make changes to managed objects associated with a given context, those changes remain local to that context until you commit the changes by sending the context a save: message. At that point—provided that there are no validation errors—the changes are committed to the store.

So does that essentially mean, that validation happens automatically as soon as I call -save?

dontWatchMyProfile
  • 42,456
  • 49
  • 169
  • 255

1 Answers1

2

Yes, validation is performed by the managed object context on save. You can manually validate an instance at any time by sending it a -validateFor[Insert|Update|Delete]:, depending on the action that will occur on context save.

Barry Wark
  • 105,416
  • 24
  • 177
  • 204
  • Oh great! Now I get it! And in case of errors, the NSError out-parameter of -save: will contain those validation error messages? – dontWatchMyProfile Jun 11 '10 at 15:39
  • Yes, the NSError out-parameter will contain the validation error(s). If there are multiple validation errors, you can retrieve the individual errors from the NSError's `userInfo` dictionary. – Barry Wark Jun 11 '10 at 17:37