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 ...
随机推荐
- 运行时报错 ADB server didn’t ACK
查看进程中所有和ADB有关的进程,全都结束了,包括什么豌豆荚之类的(大多数情况是占用端口),之后重新启动Eclipse.
- 漫游Kafka设计篇之数据持久化
Kafka大量依赖文件系统去存储和缓存消息.对于硬盘有个传统的观念是硬盘总是很慢,这使很多人怀疑基于文件系统的架构能否提供优异的性能.实际上硬盘的快慢完全取决于使用它的方式.设计良好的硬盘架构可以和内 ...
- Codeforces Round #291 (Div. 2)
A 题意:给出变换规则,单个数字t可以变成9-t,然后给出一个数,问最小能够变成多少. 自己做的时候理解成了不能输出前导0,但是题目的本意是不能有前导0(即最高位不能是0,其余位数按照规则就好) 55 ...
- C++实现顺序表
#include<iostream>using namespace std; typedef int DataType; class SeqList{public: SeqList( ...
- ffmpeg命令学习
1.组成 程序:ffmpeg.ffplay.ffprobe.ffserverffmpeg:转码程序ffplay:播放程序ffserver:服务器程序 库:libavcodec.libavdevice. ...
- 物联网操作系统HelloX已成功移植到MinnowBoard MAX开发板上
在HelloX开发团队的努力下,以及Winzent Tech公司(总部在瑞典斯德哥尔摩)的支持下,HelloX最新版本V1.78已成功移植到MinnowBoard MAX开发板上.相关源代码已经发布到 ...
- 中文分词系列(二) 基于双数组Tire树的AC自动机
秉着能偷懒就偷懒的精神,关于AC自动机本来不想看的,但是HanLp的源码中用户自定义词典的识别是用的AC自动机实现的.唉-没办法,还是看看吧 AC自动机理论 Aho Corasick自动机,简称AC自 ...
- Defining Database and Instance【数据库与实例】
Database: A collection of physical operating system files or disks. When usingOracle Automatic Stora ...
- IOS设计模式之二(门面模式,装饰器模式)
本文原文请见:http://www.raywenderlich.com/46988/ios-design-patterns. 由 @krq_tiger(http://weibo.com/xmuzyq) ...
- 定时组件quartz系列<一>模拟定时组件小程序
一.核心概念 Quartz的原理不是很复杂,只要搞明白几个概念,然后知道如何去启动和关闭一个调度程序即可. 1.Job表示一个工作,要执行的具体内容.此接口中只有一个方法void execute(Jo ...