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: Sat, 25 Jun 2005 07:35:42 -0700 (PDT)
Many thanks again for your reply.
>> 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 - but
this gets very complicated because of the nesting. I
have to removeObserver whenever one of the subarrays
changes, and so far I haven't found a simple way of
doing this (without errors about observers existing at
dealloc time, that is).
I only want to observe for changes to the properties
dictionary "title" key so that I can change it back to
what it was if necessary. Any advice on how to do this
with nested objects would be much appreciated.
Many thanks again,
Keith
---
FROM : mmalcolm crawford
DATE : Sat Jun 25 11:44:37 2005
On Jun 25, 2005, at 2:22 AM, Keith Blount wrote:
> So, accordingly, in my KBNode class, I have an
> instance variable as follows:
> NSMutableDictionary *properties;
> Thus, isn't the key "properties"? If this is the
> instance variable I want to validate (though
actually,
> I want to validate the actual keys inside the
> dictionary, which are bound to my table columns),
why
> isn't the following the correct signature?
>
> - (BOOL)validateProperties:(id *)ioValue
> error:(NSError **)outError
>
That is the correct signature. In your original post
you wrote that
you had implemented:
- (BOOL)validateProperties:(id *)ioValue
forKeyPath:(NSString *)inKeyPath error:(NSError
**)outError
and
- (BOOL)validateProperties:(id *)ioValue
forKey:(NSString *)key error:(NSError **)outError
> Thus, isn't the key "properties"? If this is the
> instance variable I want to validate (though
actually,
> I want to validate the actual keys inside the
> dictionary, which are bound to my table columns),
why
> isn't the following the correct signature?
>
If you're binding to key-value pairs *within* the
dictionary, then
when you modify a value you're not changing the
dictionary itself.
The same dictionary instance is used throughout.
Therefore the
validation method for that instance is not invoked.
> 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? (But if so, how - validation is at the model
> level, isn't it?)
>
Given the situation, this is probably best done at the
controller
level...
mmalc
____________________________________________________
Yahoo! Sports
Rekindle the Rivalries. Sign up for Fantasy Football
http://football.fantasysports.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