Accessor implementation of properties

纵饮孤独 提交于 2019-12-07 15:22:09

问题


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.


回答1:


Is there some of documentation how the compiler auto-generates the accessors of properties?

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.

The implementations are publicly available as part of the objc runtime hosted at http://www.opensource.apple.com/source/objc4/.



来源:https://stackoverflow.com/questions/10129203/accessor-implementation-of-properties

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!