黑马程序员技术交流社区

标题: @property和@synthesize [打印本页]

作者: S970028126    时间: 2015-6-28 15:16
标题: @property和@synthesize
@property(用在@interface中)和@synthesize(用在@implementation中):
        写@property int age;           //相当于写了age的set get方法声明
                                                //- (void)setAge: (int)age;
                                                //- (void)height;
        
        @synthesize age = _age;// 会把age的set get方法进行实现
                                                        //并且会访问_age这个成员变量

                  不写成员变量,会自动生成
                  高级版本@property int age做3件事情: set get方法声明和实现,定义员变量、

                 




欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) 黑马程序员IT技术论坛 X3.2