The NSKeyValueCoding
protocol is used in every sample code I've shown until now. I also have been calling it a protocol, but as I said earlier, it's an informal protocol, a NSObject
category.
KVC is a mechanism that enables you to indirectly access an object's properties, using a "key" of strings to do it. To enable KVC, NSKeyValueCoding
must be complied by your classes. Most of the time, you don't need to do anything in order to get it done because it's complied by NSObject
.
To make a key-value coding compliant class for a certain property, the methods setValue:forKey:
and valueForKey:
must be implemented to work as expected.