OC中的成員變量和屬性是不一樣的
@interface Person : NSObject{
//成員變量
NSString *name;
NSInteger age;
}
//屬性
@property (nonatomic,copy)NSString *address;
@property(nonatomic,assign)CGFloat height;
-(void)obtainInfo;
@end
屬性是用@property來定義的,屬性是用_address來訪問的,使用@property,
系統自動生成setter和getter.如果屬性只使用@property
聲明,而沒使用@synthesize
的話,系統會自動的給你聲明一個_
開頭的實例變量。如果又使用@synthesize
的話,則相當於聲明瞭一個實例變量,