属性的访问器实现 [英] Accessor implementation of properties
问题描述
是否存在一些文档,说明编译器如何自动生成属性的访问器?
Is there some of documentation how the compiler auto-generates the accessors of properties?
在编写自定义访问器(覆盖综合访问器)时,很高兴知道原始实现. 尤其是要看到具有不同(弱/强/保留/复制等)属性的访问器的不同实现.
When writing custom accessors (overriding the synthesized ones), it would be nice to know the original implementation. Especially to see the differing implementations of accessors for properties with different (weak/strong/retain/copy etc..) attributes.
推荐答案
是否有一些文档,说明编译器如何自动生成属性的访问器?
Is there some of documentation how the compiler auto-generates the accessors of properties?
编译器仅添加一个C函数调用.窥视汇编(例如_objc_getProperty
和_objc_setProperty
).
The compiler just adds a C function call. Peek at the asm (e.g. _objc_getProperty
and _objc_setProperty
).
在编写自定义访问器(覆盖综合访问器)时,很高兴知道原始实现.尤其是要看到具有不同(弱/强/保留/复制等)属性的访问器的不同实现.
When writing custom accessors (overriding the synthesized ones), it would be nice to know the original implementation. Especially to see the differing implementations of accessors for properties with different (weak/strong/retain/copy etc..) attributes.
这些实现是在 http://www托管的objc运行时中公开提供的. opensource.apple.com/source/objc4/.
这篇关于属性的访问器实现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!