//@interface系統(tǒng)關(guān)鍵字表示類聲明的開始
@interfacePeople :NSObject {
//寫在屬性聲明區(qū)域的所有實例變量都可以在本類值中的所有減號方法中使用
int age;
NSString *name;
BOOL isMarried;
float weight;
}
//一個的屬性特別多的時候如果要個屬性寫set get方法就需要寫很多個,這樣會麻煩而且代碼量非常多所以系統(tǒng)提供量一個簡單的方法可以讓我們實現(xiàn)set get方法的使用功能,而且不需要很多的代碼
//@property 系統(tǒng)關(guān)鍵字 property屬性特征的意思使用杉编。@property修飾的屬性相當(dāng)于聲明量set get方法
//格式:@property 屬性類型 屬性名肺稀;
@property int age;
//同種類型的變量可以寫到一行 @property中中間以 逗號隔開
@property BOOL sex,isMarried;
//非基本數(shù)據(jù)類型的*不公用
@property NSString*name, *nation;
@property float height,weight;
//相當(dāng)于隱式的聲明了set get方法
//-(void)setAge:(int)age;
//-(int)age
//測試為什么屬性中有age了參數(shù)不能再叫做age
- (void)test:(int)age;
//@synthesize <#property#>系統(tǒng)關(guān)鍵字 synthesize合成 @synthesize相當(dāng)余實現(xiàn)了set get方法
//格式榴徐;@synthesize屬性名;
//所有@property的屬性都可以寫到一行 @synthesize中屬性中間用逗號隔開
@synthesize age,sex,name,nation,isMarried,weight,height;
//如果這里使用age那么將使用不到屬性age的使用的只是參數(shù)age
//警告:本地變量隱藏了實例變量
//變量不要和屬性重名重名的話在變量使用區(qū)域內(nèi)會吧屬性隱藏掉