Viewing the code generated by @synthesize for getter/setter

后端 未结 2 355
失恋的感觉
失恋的感觉 2021-01-13 01:35

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

2条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-13 02:05

    Sure it is. Go to the .m file where you've @synthesized the property, then from the Build menu, choose "Show Assembly Code". The compiler conveniently puts in stuff like:

        .align  4, 0x90
    "-[Foo setStr:]":
    Leh_func_begin2:
    Lfunc_begin2:
    ....
    

    And

        .align  4, 0x90
    "-[Foo answer]":
    Leh_func_begin3:
    Lfunc_begin3:
    ....
    

    Oh, you wanted Objective-C code? Sorry, this is done by the compiler, and the compiler reads Objective-C, but writes in Assembly.

提交回复
热议问题