2

Cocoa 的键值编码使得对属性的获取/设置操作变得简单。无论如何文档说它只识别预定义的命名模式。我认为这个特性可以支持Declared Property 。实际上,Declared Property 的基本访问与 Key-Value 编码的搜索模式相同。问题是自定义访问器。因为自定义访问器存储为属性的属性,所以我认为很容易在键值编码中支持它们。但我找不到关于这个的提及。

使用自定义访问器对声明的属性使用键值编码时的常规行为是什么?

4

1 回答 1

1

If you want to use Key-Value coding, your accessor methods must conform to specific naming conventions. In the section about (custom) accessor method names, the Objective-C Programming Language Guide specifically mentions that you "should [typically] specify accessor method names that are key-value coding compliant."

For details about which names are KVC-compliant, see Accessor Search Implementation Details in the Key-Value Coding Programming Guide.

于 2011-12-13T09:37:41.910 回答