re: Core Data: is fetching safe
during validateForInsert:/validateForUpdate?



Is it OK to perform a fetch during validateForInsert:/
validateForUpdate:? I have a Core Data entity named 'Person' with an
attribute named 'uniqueNumber'. I want to ensure that no two People
have the same uniqueNumber.

It's not a great idea during validateForDelete: It fine during validateForInsert or validateForUpdate so long as the awakeFromFetch delegates and any other side effects (changes on the MOC or dirtying MOs) of fetching eventually reach a quiescent state. The canonical example of failing to do so is to update a timestamp in -willSave to the current time. Blindly. Without checking if it's already set, or equal. We'll save when the current time stops changing ...

- Ben

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@xxxxxxxxxxxxxxx)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/maillists%40codeha.us

This email sent to maillists@xxxxxxxxx

...



Privacy