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

前端 未结 4 898
一向
一向 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:35

    Some platforms support synthesized instance variables, some don't. Explicitly declaring instance variables makes your code valid in more places, and it used to be outright necessary until very recently, so people still do it. In a few years, they probably won't anymore.

提交回复
热议问题