Does correcting a value in an validation method mark the object as dirty?
From the docs:
If you change the input value in a validate:error: method, you must ens开发者_运维技巧ure that you only change the value if it is invalid or uncoerced. The reason is that, since the object and context are now dirtied, Core Data may validate that key again later. If you keep performing a coercion in a validation method, this can therefore produce an infinite loop.
So when I modify a value in a validation method, the context gets dirtied? And the next time I save, the validation happens again - and when I change the value even if the validation is OK, then the context is again dirtied, and revalidated again - and I change the value, and Core Data validates, again, because the context is dirtied. And so on...for ever... is that right? Or did they try to say something different?
Yes because you changed that value. The warning that you quoted was letting you know you can get into circular loops of validation if you keep changing multiple values in your validation methods and that your validation methods should focus on a single value at a time.
NOTE: Changing the input value is strongly discouraged in the validation methods.
精彩评论