feasible to not declare ivar but use in synthesize?

前端 未结 1 826
無奈伤痛
無奈伤痛 2021-01-26 08:35

I\'m looking at some sample code and I\'m puzzled over the lack of declaration of a specific ivar. Hoping someone can help me understand this better:

typedef NSU         


        
相关标签:
1条回答
  • 2021-01-26 09:09

    It's part of the modern runtime, and cuts down on the duplication of code - declaring iVars and then declaring properties for those iVars.

    It's handled for you by the @synthesize

    The modern runtime lets you do other things that you thought you couldn't do before. For example, you can now declare iVars in the .m file as part of a class extension, which reduces the amount of information you expose in your public interface.

    Update

    The modern LLVM 4 compiler even lets you do away with the @sytnthesize line. If you declare a property it will auto-synthesize for you and it will even create a backing store with a leading underscore.

    0 讨论(0)
提交回复
热议问题