标签:style blog io ar color sp on div log
A.@property
1 2 Student.h 3 @interface Student : NSObject 4 { 5 int _age; 6 int _no; 7 int age;//此变量不会被访问到 8 double height; 9 NSString *_name; 10 } 11 12 @property int age, no; 13 @property int height; 14 @property NSString *name; 15 16 @end
1 @implementation Student 2 3 @synthesize age = _age, no = _no, height = _height;//指定一下成员变量,否则会访问同名变量,如果不存在,就会自动生成@private的变量 4 @synthesize name = _name; 5 6 @end
1 @interface Student : NSObject 2 3 @property int age; 4 @property double height; 5 @property NSString *name; 6 7 @end
1 @interface Car : NSObject 2 3 @property int wheels; 4 5 @end
[Objective-c 基础 - 2.6] @property和@synthesize
标签:style blog io ar color sp on div log
原文地址:http://www.cnblogs.com/hellovoidworld/p/4119356.html