@interface Test : NSObject
@property (nonatomic, strong) NSString * name;
@property (nonatomic, assign) NSInteger age;
@property (nonatomic, strong) NSString * sex;
@end
@interface Test(){
NSString *_chance;
}
@end
@implementation Test
//自動(dòng)實(shí)現(xiàn)setter和getter
//@synthesize name;
//系統(tǒng)默認(rèn)是這樣滴
//@synthesize name = _name;
//但事實(shí)你可以這樣寫
@synthesize name = _chance;
//用戶自己實(shí)現(xiàn)sex的setter和getter方法
@dynamic sex;
@end
#import "SubTest.h"
@implementation SubTest
//重載父類的屬性
@synthesize sex = _sex;
@end
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者