RE: Correct way to implement validateValue:?
RE: Correct way to implement validateValue:?
- Subject: RE: Correct way to implement validateValue:?
- From: Keith Blount <email@hidden>
- Date: Fri, 24 Jun 2005 15:08:55 -0700 (PDT)
Many thanks for your reply.
> It's not clear why you're implementing this method
--
> or where.
Sorry, I thought I had been clear on this. Why:
> 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
So, like in Finder, if you try to rename a file
(represented in the outline view or table view), my
app needs to check to ensure that there is not already
a file of that name/extension that exists inside the
file wrapper (my app saves files as a number of RTFD
files inside a file wrapper). If there is, it needs to
spew an error and prevent renaming. It was my
understanding from previous posts on this list and the
docs that validateValue: might be one way of doing
this.
Where:
> 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.
So, in my model class (KBNode) in which the properties
mutable dictionary is an ivar. I don't quite know
what's unclear about that. I was following your own
manual bindings example (or rather, trying to apply
it, and evidently failing :) ).
Many thanks,
Keith
---
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