Please note: this project is inactive since early 2006

 
9.2 Behind the scenes

We have seen how to map any attribute's value to an instance of given class. Here again, this is the KeyValueCoding in action, as described in section 8.2.

The framework always accesses the attributes' values with the so-called "private" methods (storedValueForKey(), takeStoredValueForKey()). We already know that they will try to use private setters/getters -such as _setPrice() and _getPrice()- before the public ones -being getPrice() and setPrice()).

So, what happens here is:

  1. when the framework is about to save the data, it collects the attributes' value using storedValueForKey. This one finds _getprice(), which gently returns the corresponding string,

    Note: the same happens for validation before saving: type checking also calls _getPrice() and gets a string, so everything's ok.

  2. when the framework fetches the data, it uses takeStoredValueForKey() to initialize attributes' values; for the attribute price, this method finds and calls _setPrice() which turns the string back to FixedPoint.

Comments are welcome: Sebastien Bigaret / Modeling Home Page
Hosted by:SourceForge.net Logo