Re: key value validation problem
Re: key value validation problem
- Subject: Re: key value validation problem
- From: "Louis C. Sacha" <email@hidden>
- Date: Tue, 3 Feb 2004 19:34:50 -0800
Hello...
Unfortunately, the current way to do this probably requires that you
implement glue code somewhere to take care of it.
The way I prefer is to use a subclass of the formatter that
implements returning a default value in the
getObject:forString:errorDescription: method if the original
implementation returns nil. When a textfield is left blank, returning
your default value instead of nil from the formatter will result in
the default value being used both to make the string representation
in the textfield and to return as the object value.
You could also have your controller object explicitly set the object
value when your validation method gets a nil value, but I prefer
using the formatter subclass since I've made a "standard" set of
formatter subclasses for the cocoa provided ones that I use all the
time that allow me to choose what default value to be used (if any),
and choose if partial validation should be active.
Hope that helps,
Louis
Hello,
I have a text field with a date formatter attached. If the user deletes
the text and tabs out I want to set the field to the current date so as
not to leave the field empty. My validation method is called when the
user tabs out and the model is updated but the UI is not updated. How
do I get the UI updated?
- (BOOL)validateDate:(id *)ioValue error:(NSError **)outError
{
if (*ioValue == nil)
{
// set date to today
*ioValue = [NSCalendarDate calendarDate];
}
return YES;
}
Ken Grigsby
email@hidden
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.