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
accessInstanceVariablesDirectly
returnsYES
, 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 theNSArray
class) and<key>AtIndexes:
(corresponding to theNSArray
methodobjectsAtIndexes:
).If the
countOf<Key>
method and at least one of the other two possible methods are found, a collection proxy object that responds to allNSArray
methods is returned. EachNSArray
message 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 theNSSet
class).If all three methods are found, a collection proxy object that responds to all
NSSet
methods is returned. EachNSSet
message 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
accessInstanceVariablesDirectly
returnsYES
, 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 byNSNumber
conversion is done and anNSNumber
is returned. Otherwise, conversion is done and anNSValue
is returned. Results of arbitrary types are converted toNSValue
objects, not justNSPoint
,NSRange
,NSRect
, andNSSize
types.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 ...
随机推荐
- linux 2.6up的设备和设备驱动模型
在linux2.6 的设备和设备驱动模型构架中,所有的外部设备和驱动程序都挂在总线上 ,总线分为(usb -- USB设备,PCI -- PCI 设备 platform -- 直接和处理器进 ...
- js,正则应用
//获取URL中的request参数 function getUrlParam(name) { var reg = new RegExp("(^|&)" + name + ...
- 二、CSS 基本介绍
[ 显示目录 ] [ 隐藏 ] 目录 基本概念 CSS组成部分 CSS的规则 引入CSS样式的方法 颜色的表示 CSS Reset 选择器分类 浮动 盒子模型 box-sizing属性 实例:实现“田 ...
- matlab中,在灰度解剖图上叠加阈值图,by by DR. Rajeev Raizada
1.参考 reference 1. tutorial主页:http://www.bcs.rochester.edu/people/raizada/fmri-matlab.htm. 2.speech_b ...
- struts2拦截器配置;拦截器栈;配置默认拦截器;拦截方法的拦截器MethodFilterInterceptor;完成登录验证
struts2.xml 内容 <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE struts ...
- Excel 之查找与替换
Excel查找与替换 1,一旦学会查找,替换就简单了. 2,查找下面有一个选项,里面有对查找的范围进行限制 3,你可以选中一个区域,然后再查找,查找只会在你选择的区域里面进行 4,查找只能找特定值,而 ...
- ORACLE创建、修改、删除序列
ORACLE没有象SQL SERVER中一样的自增加字段,要实现只能通过SEQUENCE来实现. 1.创建序列语法:(需要CREATE SEQUENCE系统权限) CREATE SEQUENCE 序列 ...
- Android 高仿腾讯旗下app的 皮肤加载技术
http://www.cnblogs.com/punkisnotdead/p/4968851.html 以前写的这篇文章 可以高仿出 知乎 新浪微博等 绝大多数app的换肤技术,但是遗漏了腾讯的效果, ...
- @错误抑制运算符和or die()
1.错误抑制运算符可在任何表达式前使用,PHP支持一个错误抑制运算符@.当将其放置在一个PHP表达式之前,则该表达式可能产生的任何错误信息都被忽略掉.@运算符只对表达式有效. 2.or die() 当 ...
- C#实现CAD数据转shape或mdb
jojojojo2002 原文C#实现CAD数据转shape或mdb 本文所指的CAD数据为不带空间参考和扩展数据的数据.如果CAD带了空间参考或是扩展属性数据的话,就要采用图形和属性分离的方法转CA ...