@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
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容