@synthesize和@dynatmic

@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

//自动实现setter和getter
//@synthesize name;

//系统默认是这样滴
//@synthesize name = _name;

//但事实你可以这样写
@synthesize name = _chance;

//用户自己实现sex的setter和getter方法
@dynamic sex;

@end
#import "SubTest.h"

@implementation SubTest

//重载父类的属性
@synthesize sex = _sex;

@end

你可能感兴趣的:(@synthesize和@dynatmic)