iOS Objective-C 重写 setter 方法


ARC的时候直接赋值就可以了


- (void)setObject:(NSObject *)object   // retain
{
    if (_object == object) {
        return;
    }
    [_object release];  
    _object = [object retain];  
}


- (void)setString:(NSString *)string  //copy
{
    [_string release];  
    _string = [string copy];  
}

你可能感兴趣的:(ios,Objective-C,setter)