Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Custom alerts for Core Data validation errors ... how to?



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:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.