成员变量、实例变量和属性

@interface LGPerson ()
@property (nonatomic, copy) NSString *name;
@end
@implementation LGPerson{
    NSString *_hobby;//成员变量
    int age;//成员变量
    UIButton *hookBtn; //实例变量(特殊的成员变量)
}

属性: @property 修饰的变量
成员变量: @implementation LGPerson{ } 大括号中声明的变量
实例变量: 特殊成员变量, 可实例化, 可理解为声明的变量可以添加属性的为实例变量, _hobbyNSString, 无法为string添加属性, 为基础数据类型变量; 而hookBtn可以设置颜色... 为对象类型

属性(property) = set + get + ivar(成员变量)

@synthesize@dynamic的使用可参考@synthesize 和 @dynamic 关键词

你可能感兴趣的:(成员变量、实例变量和属性)