Custom alerts for Core Data validation errors ... how to?
Custom alerts for Core Data validation errors ... how to?
- Subject: Custom alerts for Core Data validation errors ... how to?
- From: Richard Wolf <email@hidden>
- Date: Thu, 29 Nov 2007 20:33:13 -0600
Guys,
I have kind of an extremely dumb question ... yet despite my
Googling, I cannot find an answer to it.
I have a Core Data application and I have used the data model to do
various validations ... mostly regular expression matches on
strings. It works great, but I'd like to customize the validation
alerts that are generated when validation fails. For example, if a
typical validation fails, the "standard" alert says something like:
Shard secret is invalid.
But I'd like to change that to something like this:
The string you have entered does not appear to be a shared secret.
A shared secret must be exactly 32 characters long and contain
only letters and numbers. Discard changes or try again?
"Normally" I'd be able to provide my own validation methods and craft
the NSErrors ... but this is Core Data ... and the object model is
doing the validation for me. I'm happy with the way the object model
is doing validation ... I just want to customize the error
descriptions, recovery suggestions, and recovery options in the
validation alert by way of my own NSErrors. The NSPersistentDocument
tutorial shows a way to NSDocuments -willPresentError delegate method
to present a custom alert ... I -could- go that route ... but then
I'd be doing jillions of tests ("is it this error? ... No, okay, this
error? ... etc.). I basically want something that has the
functionality of "OK, object model says this isn't valid ... so use
this NSError in the alert that displays") within my managed object
subclasses ... something like what validateSharedSecret:(id *)ss
error:(NSError *)outError; does ... without tacking on the extra
error if I return "NO". Alternatively, I'll be happy to somehow
validate using a regular expression within my own validator (i.e.,
let my custom validator do the work rather than the data model).
Does this make any kind of sense?
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden