Re: Visual feedback of invalid cell data from Core Data - how to?
Re: Visual feedback of invalid cell data from Core Data - how to?
- Subject: Re: Visual feedback of invalid cell data from Core Data - how to?
- From: Quincey Morris <email@hidden>
- Date: Sat, 19 Mar 2011 14:55:52 -0700
On Mar 19, 2011, at 13:44, Luke Evans wrote:
> I definitely want the regular Core Data validation process to propagate and
> drive this, rather than having to set formatters on all my cell (or
> something) and manually figure out validation by some means.
I think your want might be internally self-inconsistent, but it depends what you mean by "regular" Core Data validation. It's not clear if you're trying to rely on entity value constraints in the Core Data model, or validate<Key> methods in managed object subclasses, or something else.
I think you have to ask yourself:
Can I tolerate having invalid values stored in my data model, even temporarily?
If the answer is YES, then I'd suggest you don't handle this as property-level validation in the usual sense. Instead, create some derived 'isXXXValid' properties in your managed object subclass, which uses 'keyPathsForValuesAffectingIsXXXValid' to get KVO compliance. Bind something in your UI to these properties to decide what background color to use.
In this case, you'd add code at (say) save time to re-check for validation errors and put up an alert. I believe this kind of deferred validation is discussed in the Core Data documentation.
If the answer is NO, then you're going to have to create intermediate or shadow properties, say in the window controller, which *are* allowed to be invalid, and then figure everything out from there, using the above technique or something different.
In this case, you'd have to transfer the values into the model at (say) save time, provided they're valid at that point.
Note that Core Data doesn't give a damn if you pollute your data model with invalid attribute values, even violations of entity-declared constraints, until it gets to a save. At that point it will refuse to save if there are any errors it can detect, and return an entire array of error objects.
_______________________________________________
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