Re: Correct way to implement validateValue:?
Re: Correct way to implement validateValue:?
- Subject: Re: Correct way to implement validateValue:?
- From: mmalcolm crawford <email@hidden>
- Date: Sat, 25 Jun 2005 11:45:08 -0700
On Jun 25, 2005, at 7:35 AM, Keith Blount wrote:
Given the situation, this is probably best done at
the controller level...
Given that I am using nested objects, what is the best
way to do this? I have been using straightforward KVO
- registering my controller as the observer of the
"title" key of the model's properties dictionary
Do you need to do this in your model class, or can you simply
validate values as they're entered in the UI (as you seemed to imply
here:
Also, is this even the best approach when what I
actually want to do is to check that the file being
renamed doesn't already exist on disk? Shouldn't I
really be doing this in my controller rather than my
model?
)? Whilst less "academically pure" than putting validation logic
into the model, this would seem to be a rather easier pragmatic
solution. Alternatively, is there any reason why the "title"
attribute must be stored in a dictionary, or at least why you cannot
provide accessor methods that abstract the attribute?
- (NSString *)title
{
return [propertiesDictionary objectForKey:@"title"];
}
- (void)setTitle:(NSString *)newTitle
{
[propertiesDictionary setObject:newTitle forKey:@"title"];
}
You could then readily implement a validateTitle:error: method...
mmalc
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden