搜索
您的当前位置:首页正文

属性的setter、getter方法

来源:二三娱乐
// 申明属性
@property (nonatomic, copy) NSString *contentText;
// setter方法
- (void)setContentText:(NSString *)contentText {
    _contentText = contentText;
}
// getter方法
- (NSString *)contentText {
    return _contentText;
}

同时写settergetter方法时,需要在 @implementation 中写
@synthesize contentText = _contentText;

Top