views:

23

answers:

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?

+2  A: 

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
Oh great! Now I get it! And in case of errors, the NSError out-parameter of -save: will contain those validation error messages?
dontWatchMyProfile
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