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 ...

Get Objective-C Quick Syntax Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.