Correct way to implement validateValue:?
Correct way to implement validateValue:?
- Subject: Correct way to implement validateValue:?
- From: Keith Blount <email@hidden>
- Date: Fri, 24 Jun 2005 13:09:10 -0700 (PDT)
Hello,
I have an object class, KBNode, which is used both as
the nodes in an NSTreeController controlling an
outline view and as the object in the array of an
NSArrayController controlling an NSTableView. My node
object has an NSMutableArray called properties with
several keys - "title", "description" and "ID" - which
are bound to the columns in the views.
These nodes represent files on the disk inside a file
wrapper, so I would like to check whenever the user
tries to edit the title of a node to ensure that a
file of that name does not already exist within the
file wrapper. I have the following problems, and would
be grateful to anyone who could tell me how to address
them:
1) I think I need to implement validateValue: in my
model class to validate the value when it changes.
What I need to check is the "title" value inside the
properties mutable dictionary. However, I have tried
to do this but it never seems to get called. I have
tried:
- (BOOL)validateProperties:(id *)ioValue
forKeyPath:(NSString *)inKeyPath error:(NSError
**)outError
{
NSLog (@"validateProperties:forKeyPath:error");
return YES;
}
and
- (BOOL)validateProperties:(id *)ioValue
forKey:(NSString *)key error:(NSError **)outError
{
NSLog (@"validateProperties:forKey:error:");
return YES;
}
However, neither ever gets called. I should stress
that I have set "validates immediately" everywhere I
can think of - in my tree controller, in my array
controller, in the table columns of both views... but
with no joy.
2) Another problem arises in where to check whether a
file with the name the value is being changed to
already exists on disk. It seems as though I should be
validating the value in my model object, but if my
model object needs to know where the file wrapper is
saved on disk so that it can check the files inside it
in order to validate, it seems that this would be bad
design. Any suggestions?
Many thanks for any help.
All the best,
Keith
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
_______________________________________________
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