A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

  1. #import <Foundation/Foundation.h>
  2. @interface Person : NSObject
  3. {
  4.     int _age;
  5.     int _height;
  6.     double _weight;
  7.     NSString *_name;
  8. }

  9. // @property:可以自动生成某个成员变量的setter和getter声明
  10. @property int age;

  11. @property int height;

  12. @property double weight;

  13. @property NSString *name;

  14. @end
复制代码
上面的四条@property语句的功能就相当于一下代码:
  1. #import <Foundation/Foundation.h>

  2. @interface Person : NSObject
  3. {
  4.     int _age;
  5.     int _height;
  6.     double _weight;
  7.     NSString *_name;
  8. }

  9. - (void)setAge:(int)age;
  10. - (int)age;

  11. - (void)setHeight:(int)height;
  12. - (int)height;

  13. - (void)setWeight:(double)weight;
复制代码



0 个回复

您需要登录后才可以回帖 登录 | 加入黑马