1、@property关键字的作用是:自动生成getter、setter方法的声明;
2、语法:
@property 数据类型 名称;
3、原理:编译器在编译时,会根据@property生成getter和setter方法的实现。
4、@synthesize关键字的作用是:自动生成gette、setter方法的实现;
5、语法:
@synthesize @property 名称;
6、做的事情:
a、生成1个真私有属性;
b、将参数直接赋值给自动生成的那个私有属性,并没有做任何逻辑验证。如果需要getter和setter有自己的逻辑验证,那么就自己重写;
c、将生成的私有属性返回。
7、@property增强
生成私有属性,并且生成getter和setter的声明和实现。