http://blog.csdn.net/developer_zhang/article/details/12840567
1 Preface
In this section we mainly introduce key-value encodings and how to make a class conform to KVC encoding.
2 Details
Key-value encoding is a mechanism for indirectly accessing an object's properties and relationships using character identifiers. It supports or relationships several special cocoa programming mechanisms and techniques, in the core data,application scriptability, binding technology (application scriptability and binding technology specifically belongs to the OS X) and the language attribute of the declaration attribute. We can also use key-value coding to simplify our program code.
2.1 Object Properties and KVC
The core of Key-value encoding (or KVC) is the general concept of attributes. An attribute that involves pressing an object into a state cell. A property can be one of two common types: a property (for example: name,title) or a relationship to another object. The relationship can be one or the other. A typical representation of a value of a multi-relationship is an array (array) or set, depending on whether the relationship is ordered or unordered.
KVC locates an object property by using a string-marked key. A key usually conforms to the name or instance variable of the stored method defined by the object. Key must conform to a fixed convention: ASCII encoding must begin with lowercase letters and no spaces. The key path is a string of points that are separated by a string keys that are used to simplify the traversal of the sequence of object properties. The first key of the sequence of attributes is associated with a simple object (Employee1 in the following graph), and the subsequent key is the property of the associated preceding value.
2.2 Making a class conform to KVC encoding
nskeyvaluecoding informal agreements make KVC known as possible. Its two methods-valueforkey: and setvalue:forkey:-are particularly important because they get and set a property value when the key is provided. NSObject provides a default implementation of these methods, and when a class obeys a key-value encoding, it can rely on this implementation
How we can make a property conform to KVC encoding depends on whether these properties are properties of an object, a relationship to one, or a multiple relationship. For these attributes and relationships, a class must conform to at least one of the following (key equals property key):
(1) Using the name key, the class has a declaration attribute;
(2) It implements the storage method called key and, if the property is mutable, Setkey: (If the property is a Boolean property, the Getter storage method has the IsKey format);
(3) It declares an instance variable in the form of key or _key.
Implementing the KVC format for a one-to-many relationship is a more complex step.
3 Conclusion
The above is all the content, hope to help you.
iOS deep Learning (21) Key-value coding