How to properly use CoreData validation & error framework ?

Posted by Xav on Stack Overflow See other posts from Stack Overflow or by Xav
Published on 2010-06-16T15:10:10Z Indexed on 2010/06/17 3:13 UTC
Read the original article Hit count: 305

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 %@" ?

© Stack Overflow or respective owner

Related posts about iphone-sdk

Related posts about iphone-sdk-3.0