查看@synthesize为getter / setter生成的代码 [英] Viewing the code generated by @synthesize for getter/setter
问题描述
是否可以查看@synthesize生成的确切代码?
生成getter和setter方法的C ++代码:
http://llvm.org/svn/llvm-project/cfe/trunk/lib/CodeGen/CGObjC.cpp
您还可以在应用运行时实现。虽然不是字面上与生成的代码相同,但是这个代码更容易阅读,并清楚地表明适当的getter和setter应该做什么。
Is it possible to view the exact code generated by @synthesize?
You can read the Clang compiler source to see the C++ code that generates the getter and setter methods:
http://llvm.org/svn/llvm-project/cfe/trunk/lib/CodeGen/CGObjC.cpp
It's pretty cryptic but that's the most accurate way of seeing the code generated.
You can also look at the objc_getProperty and objc_setProperty implementations in Apple's runtime implementation. While not literally the same as the code that is generated, this code is much easier to read and gives a clear indication of what a proper getter and setter should do.
这篇关于查看@synthesize为getter / setter生成的代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!