Table of Contents Previous Section
Changes to Key-Value Coding
In release 3.0, Enterprise Objects Framework makes slight changes to key-value coding:
- The implementations of the primitive key-value coding methods resolve their keys differently: the search order for resolving the key has changed and the valueForKey methods now support Java-style getter methods (such as getKey). More detailed information on the search order is provided in the table below.
- A new method, storedValueForKey:, has been added to the set of primitive key-value coding methods. It is the corresponding getter method to takeStoredValue:forKey: (Objective-C) and takeStoredValue (Java).
- The methods takeStoredValue:forKeyPath: and takeStoredValuesFromDictionary: have been removed.
Stored Value Methods
The stored value methods, storedValueForKey: and takeStoredValue:forKey: (storedValueForKey and takeStoredValueForKey in Java), are used by the framework when accessing properties of an enterprise object to get or set properties for state storage and restoration (either from the database or to an in-memory snapshot). This access is considered private to the enterprise object and is invoked by the Framework to effect persistence on the object's behalf.
void setBonus(double newBonus) {This code should be activated when the object is updated with values provided by a user through the application's user interface, but not when the bonus property is restored from the database. Since the Framework restores the property using takeStoredValue:forKey: (takeStoredValueForKey in Java) and since this method accesses the _bonus instance variable in preference to calling the accessor, the unnecessary (and possibly harmful) recomputation of _total is avoided. If the object actually wants to intervene when a property is set from the database, it has two options:
willChange();
_total += (newBonus - _bonus);
}
- Implement _setBonus:
- Turn off stored accessors by overriding the class (Objective-C) or static (Java) method useStoredAccessor to return NO or false.
Table of Contents Next Section