KVC compliance and validation
KVC compliance and validation
- Subject: KVC compliance and validation
- From: Richard Stacpoole <email@hidden>
- Date: Sun, 28 May 2006 23:06:25 +1000
Hi,
I am creating an application that creates stylised side view drawings
of the components of water monitoring wells for a large salinity
monitoring project. I am making the data model (not using Core Data)
KVC (& KVO) compliant and would like to use the validation methods.
There are several occasions where I need to ensure an array of values
is in ascending order, but not from sorting. An example is storing
the depth of fill components in millimeters starting at ground level
equals 0 and measuring depth:
cement cap 300
bentonite seal 1300
gravel fill 8700 etc.
although typically there are 15 fill components to a well, all
represented in a table view.
The problem is I don't know how to use the KVC validation method to
ensure that the components each have a depth given:
The Key-Value Coding Programming Guide article on ensuring KVC
Compliance states:
▪ Your implementation of the -set<Key>: method should not perform
validation.
I found one email <http://www.cocoabuilder.com/archive/message/cocoa/
2003/11/19/85609> reply on this issue from mmalc:
"Umm, what's wrong with directly using the nice clean interface
provided
by the validation methods you implement in the model...? You call the
validation method if you want, otherwise you don't."
But I don't understand where to use the validation methods if you
can't use them in the -set<key> method. I somehow have to have some
method call the validation method which checks values in the array
(so it must be able to freely access values in the array) and then
use KVC -set<key> to enter a valid value. But what is that method?
Regards,
Richard Stacpoole
_______________________________________________
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