Objective C: Why do we declare ivars in the .h member area if @property seems to do it automatically?

前端 未结 4 872
一向
一向 2020-12-16 14:55

In implementing an interface it seems the common method in tutorials and literature is to declare an ivar and then set the @property then @synthesize

4条回答
  •  时光说笑
    2020-12-16 15:36

    The @property only implements the accessor methods, the instance variable itself has to exist. Try ignoring the ivars and it will fail on runtime, if not on compile time.

提交回复
热议问题