Re: Custom alerts for Core Data validation errors ... how to?
Re: Custom alerts for Core Data validation errors ... how to?
- Subject: Re: Custom alerts for Core Data validation errors ... how to?
- From: Richard Wolf <email@hidden>
- Date: Fri, 30 Nov 2007 14:30:26 -0600
On Nov 30, 2007, at 4:24 AM, mmalc crawford wrote:
On Nov 30, 2007, at 2:33 AM, Richard Wolf wrote:
"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.
Why not just implement your own managed object validation methods?
Well, I've thought about that, I really have. Problem is this:
In the data modeling tool in XCode, I have my entity defined nice and
neat ... and the settings for my "sharedSecret" attribute are all
laid out ... including the "Reg. Ex." text string ...
[A-Z0-9]{32,32}
I aspire to be a good, lazy programmer ... let the data modeling tool
hang onto the regex if I can get away with it. But if I do that, the
only control I have over the error alert (short of doing a view/
window/doc delegate) is how the attribute name appears ... I can go
from "sharedSecret" to "Shared secret".
Now I'm more than happy to move that regex string into a
-(BOOL)validateSharedSecret:(id *)ioValue error:(NSError **)outError
method in my NSManagedObject subclass. But what I can't find is a
way to do this:
BOOL result = [*ioValue matchesRegularExpression:@"[A-Z0-9]{32,32}"];
At least, so far as I know, there is no Apple-approved way to do
that. I could glom onto another Cocoa regex class, but I thought
that ... somehow ... CoreData already knows how to do that ... so
I'll do the work if I have to, but if there is some way to do it
simply, I'd super-appreciative ("buy you a beer" appreciative) to
know how.
Thanks Malcolm!
_______________________________________________
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