查看@synthesize为getter / setter生成的代码 [英] Viewing the code generated by @synthesize for getter/setter

查看:120
本文介绍了查看@synthesize为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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆