O'Reilly logo

Objective-C Quick Syntax Reference by Matthew Campbell

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

CHAPTER 21

image

Key-Value Coding

Key-Value Coding Defined

Normally when you want to get or set property values in an object you use dot notation to get a reference to the property to change the value. However, with key-value coding you can store and retrieve property values indirectly using string keys. Applications that require archiving need this type of functionality so that apps can retrieve object data from archive files.

Setting Property Values

You can use key-value coding to set property values. To set property values, you must use the setValue:forKey: message and provide the new property value and the NSString name of the property.

[p setValue:@"New ...

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