Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Viewing the code generated by @synthesize for getter/setter

Is it possible to view the exact code generated by @synthesize?

like image 626
cfischer Avatar asked Oct 13 '10 16:10

cfischer


1 Answers

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.

like image 56
Matt Gallagher Avatar answered Oct 02 '22 22:10

Matt Gallagher