O'Reilly logo

Objective-C Memory Management Essentials by Gibson Tang, Maxim Vasilkov

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The NSKeyValueCoding protocol

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.

Compliance of attributes and one-to-one relationships

You must ensure that your class has the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required