MRC下set和get方法的重写

 

@interface List : NSObject
{
    NSString *_name;
}
-(void)setName:(NSString *)name;
-(NSString *)name;
@end 

 

@implementation List
-(void)setName:(NSString *)name
{
    if (_name!=name) {
    [_name release];
    _name=[name retain];
    }
}
-(NSString *)name
{
    return _name;
}
@end

 

posted @ 2021-03-10 11:05  黄增松  阅读(145)  评论(0编辑  收藏  举报