Student.h

 1 #import <Foundation/Foundation.h>
 2 
 3 @interface Student : NSObject
 4 {
 5     // 实例变量命名 以 _开头,和系统命名规范一致;
 6     
 7     //1:public的实例变量可以用 -> 方式访问;
 8 @public
 9     NSString *_publicName;
10     //2:默认为protected 权限;子类可以继承;
11 @protected
12     NSString *_protectedName;
13     
14     //4:@property 使用系统 会加 _的实例变量,如果不加;
15     float number; //这是一个实例变量  和系统 加的 _bumber是两个;用@synthesize number 把系统加的 _的 等于 当前的 number;
16 }
17 
18     //3:只写一个 @property age;默认加上 getter,setter方法 和一个 实例变量 _age;
19 @property(nonatomic,readwrite,assign)int age;   //相当于加setter , getter , 并加实例变量 _age;
20 
21 
22     //4:@property 与 @synthesize;
23 @property(nonatomic,readwrite,assign)float number;
24 
25 
26 - (void)sayHello;
27 @end
View Code

相关文章: