ios interface iVar vs Property

后端 未结 2 1216
轮回少年
轮回少年 2021-02-08 08:39

In an .h file, what is the difference between:

@interface ViewController : UIViewController
@property (strong, nonatomic) UIView* myView;

And <

2条回答
  •  太阳男子
    2021-02-08 09:03

    The first one is the declaration of a property, whereas the second is only a ivar. A property is the automatic declaration of a getter and a setter for an ivar, but if there is not ivar (like in your first example) the property will create the ivar too.

提交回复
热议问题