How to properly use CoreData validation & error framework ?
- by Xav
I've created a model in Xcode, and for various attributes I have minimum & maximum values defined and that are enforced by coreData at runtime.
I'm using NSManagedObject validateValue:forKey:error to check for user input values.
I was a bit disappointed to see that the localized error message is not specific, and I get a "The operation couldn't be completed. (Cocoa error 1620)" for too small values and a "The operation couldn't be completed. (Cocoa error 1610)" for too large values.
It's written in the coreData documentation that "you can localize most aspects of a managed object model, including entity and property names and error messages". Unfortunately it's not very detailed on how you implement it for error messages.
So How do you customize error message ? How do you localize them ?
Is it possible to customize it in a way where it will mentioned the reference value ex: "Value should be lower than %@" or "Value should be higher than %@" ?