Accessor Search Implementation Details
[Accessor Search Implementation Details]
Key-value coding attempts to use accessor methods to get and set values, before resorting to directly accessing the instance variable.
Key-value coding 优先使用accessor methods走获取与设置数据,之后再使直接访问instance variable.
[Accessor Search Patterns for Simple Attributes]
Default Search Pattern for setValue:forKey:
When the default implementation of setValue:forKey: is invoked for a property the following search pattern is used:
The receiver’s class is searched for an accessor method whose name matches the pattern
set<Key>:.If no accessor is found, and the receiver’s class method
accessInstanceVariablesDirectlyreturnsYES, the receiver is searched for an instance variable whose name matches the pattern_<key>,_is<Key>,<key>, oris<Key>, in that order.If a matching accessor or instance variable is located, it is used to set the value.
If no appropriate accessor or instance variable is found,
setValue:forUndefinedKey:is invoked for the receiver.
Default Search Pattern for valueForKey:
When the default implementation of valueForKey: is invoked on a receiver, the following search pattern is used:
Searches the class of the receiver for an accessor method whose name matches the pattern
get<Key>,<key>, oris<Key>, in that order. If such a method is found it is invoked.Otherwise (no simple accessor method is found), searches the class of the receiver for methods whose names match the patterns
countOf<Key>andobjectIn<Key>AtIndex:(corresponding to the primitive methods defined by theNSArrayclass) and<key>AtIndexes:(corresponding to theNSArraymethodobjectsAtIndexes:).If the
countOf<Key>method and at least one of the other two possible methods are found, a collection proxy object that responds to allNSArraymethods is returned. EachNSArraymessage sent to the collection proxy object will result in some combination ofcountOf<Key>,objectIn<Key>AtIndex:, and<key>AtIndexes:messages being sent to the original receiver ofvalueForKey:. If the class of the receiver also implements an optional method whose name matches the patternget<Key>:range:that method will be used when appropriate for best performance.Otherwise (no simple accessor method or set of array access methods is found), searches the class of the receiver for a threesome of methods whose names match the patterns
countOf<Key>,enumeratorOf<Key>, andmemberOf<Key>:(corresponding to the primitive methods defined by theNSSetclass).If all three methods are found, a collection proxy object that responds to all
NSSetmethods is returned. EachNSSetmessage sent to the collection proxy object will result in some combination ofcountOf<Key>,enumeratorOf<Key>, andmemberOf<Key>:messages being sent to the original receiver ofvalueForKey:.Otherwise (no simple accessor method or set of collection access methods is found), if the receiver's class method
accessInstanceVariablesDirectlyreturnsYES, the class of the receiver is searched for an instance variable whose name matches the pattern_<key>,_is<Key>,<key>, oris<Key>, in that order. If such an instance variable is found, the value of the instance variable in the receiver is returned. If the type of the result is one of the scalar types supported byNSNumberconversion is done and anNSNumberis returned. Otherwise, conversion is done and anNSValueis returned. Results of arbitrary types are converted toNSValueobjects, not justNSPoint,NSRange,NSRect, andNSSizetypes.If none of the above situations occurs, returns a result the default implementation invokes
valueForUndefinedKey:.
Accessor Search Implementation Details的更多相关文章
- 17.2.1 Replication Implementation Details 复制实现细节:
17.2 Replication Implementation 复制是基于master server 跟踪所有改变到他的数据库(更新,删除等等)在它的binary log. binary log 作为 ...
- [Angular] Extract Implementation Details of ngrx from an Angular Application with the Facade Pattern
Extracting away the implementation details of ngrx from your components using the facade pattern cre ...
- The implementation details of the built thermal setup
Lucid infrared thermography of thermally-constrained processors
- iOS修改声明为readonly的属性值
本文讨论的是,对于类中声明为 readonly 的属性值,我们就不可以修改其值了么?如何可以,那么如何修改呢? 为了便于说明,定义一个 ACLStudent 的类: ACLStudent.h @int ...
- 论文笔记:Auto-DeepLab: Hierarchical Neural Architecture Search for Semantic Image Segmentation
Auto-DeepLab: Hierarchical Neural Architecture Search for Semantic Image Segmentation2019-03-18 14:4 ...
- (转)The Evolved Transformer - Enhancing Transformer with Neural Architecture Search
The Evolved Transformer - Enhancing Transformer with Neural Architecture Search 2019-03-26 19:14:33 ...
- Foundation: Binary Search
/* Binary search. * * Implementation history: * 2013-10-5, Mars Fu, first version. */ /* [Binary Sea ...
- 17.2?Replication Implementation 复制实施:
17.2?Replication Implementation 复制实施: 17.2.1 Replication Implementation Details 17.2.2 Replication R ...
- [转]An overview of Openvswitch implementation
This is NOT a tutorial on how to use openvswitch, this is for developers who want to know the implem ...
随机推荐
- Sencha CMD 4- 安装与首次使用
哥英文不好,网上搜索好多中文教程都是抄来抄去没有完整的介绍.所以写出来让与我一样的小伙伴惊呆下! 这篇主要是安装,后续慢慢更新 一.Sencha CMD是干啥滴!? 它是服务使用EXTJS SDK开发 ...
- HDU 3537 (博弈 翻硬币) Daizhenyang's Coin
可以参考Thomas S. Ferguson的<Game Theory>,网上的博客大多也是根据这个翻译过来的,第五章讲了很多关于翻硬币的博弈. 这种博弈属于Mock Turtles,它的 ...
- Git之 基本常用命令
Git基本常用命令如下: mkdir: XX (创建一个空目录 XX指目录名) pwd: 显示当前目录的路径. git init 把当前的目录变成可 ...
- VBScript - CUD registry key and value
http://msdn.microsoft.com/en-us/library/aa384906(v=vs.85).aspx HKEY_LOCAL_MACHINE = &H80000002 s ...
- 【Python】控制流语句、函数、模块、数据结构
1.三种控制流语句:if\for\while 2.每句后都要加冒号 3.有elif语句=else后加一个if 注意使用变量名! 注意缩进! 注意控制流语句后面要加冒号! 4.for i in rang ...
- Centos6.5自带mysql的启动
CentOS6.5选择web server版本,安装完以后,用rpm -qa | grep mysql 发现已经安装, 但是使用service mysqld start 显示mysqld命令不存在,后 ...
- phonegap 检查是否有网络
在主active onCreate函数中实现 @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(sa ...
- Oracle 中的 TO_DATE 和 TO_CHAR 函数
Oracle 中的 TO_DATE 和 TO_CHAR 函数oracle 中 TO_DATE 函数的时间格式,以 2008-09-10 23:45:56 为例 格式 说明 显示值 备注 Year(年) ...
- 【转】eclipse安装shell编辑插件shellEd
原文网址:http://blog.csdn.net/just_lion/article/details/7764777 1. 安装man page viewer Help->Install Ne ...
- 【转】WCF和ASP.NET Web API在应用上的选择
文章出处:http://www.cnblogs.com/shanyou/archive/2012/09/26/2704814.html 在最近发布的Visual Studio 2012及.NET 4. ...