iOS arc和mrc下重写set方法

ARC下
@property (nonatomic, weak/assign) id delegate;
相当于

  • (void)setDelegate:(id< MyDelegate >)delegate
    {
    if (_delegate != delegate) {
    _delegate = delegate;
    }
    }

MRC下
@property (nonatomic, strong/retain/copy) id< MyDelegate > delegate;
相当于

  • (void)setDelegate:(id< MyDelegate >)delegate
    {
    if (_delegate != delegate) {
    [_delegate release];
    _delegate = [delegate retain/copy];
    }
    }

你可能感兴趣的:(iOS arc和mrc下重写set方法)