Re: Tuning KVO validation.
Re: Tuning KVO validation.
- Subject: Re: Tuning KVO validation.
- From: Óscar Morales Vivó <email@hidden>
- Date: Thu, 26 Feb 2004 11:39:07 +0100
I agree that a custom formatter would solve my problem in this case, I
just don't think it's the 'best' solution.
Before anyone complains, I'm going to file an enhancement request about
this ;o)
As I see it, validation is the responsibility of the model, and the
validate<key>:error: methods allow for implementing it nicely. However,
the place for responding to the validation error should be the
controller layer, as the response depends on the application logic and
flow. On a failed validation, there should be some delegate method
called or notification sent by whoever called the validation method.
I'd personally vouch for a delegate method for the NSController (I
guess they'll get delegates sometime in the not so far away future)
like the following:
- (void)validationFailedForKey:(NSString*)theKey error:(NSError*);
And/or having a delegate for the controls like the following:
- (void)validationFailed:(NSError*);
or
- (void)validationFailed:(NSNotification*) if notifications were used.
Meanwhile I guess I'll just implement the custom formatter ;o)
Hope that helps.
Sscar Morales Vivs
On 25 Feb 2004, at 15:44, Thomas Moore wrote:
IMO, the thing to do is write a custom NSFormatter object. I use
these for special cases, such as when no spaces are allowed, or to add
percents, etc. In a custom formatter, you'd just place rules in there
about valid input.
Tom
On Feb 25, 2004, at 8:03 AM, Sscar Morales Vivs wrote:
It may not allow it, but it should. There should be a mechanism
(maybe there is and I just haven't found it) to capture the model's
validation errors and act on them. Otherwise I'm doing redundant
validating, which is bad style and makes the code harder to maintain.
On 25 Feb 2004, at 14:47, Allan Odgaard wrote:
On 25. Feb 2004, at 14:42, Sscar Morales Vivs wrote:
And I don't have anything against that behaviour, as I already
understood why it is set so. I just want to be able to specify the
one I want too.
Then implement textView:shouldChangeTextInRange:replacementString:
in your delegate (of the field editor) and let it return NO (and do
NSBeep()) when you see an illegal string.
The binding system nor the formatter system is made for that.
_______________________________________________
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.
_______________________________________________
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.