self.xxx = nil 可以等效于[_xxx release] _xxx= nil 么

如果属性是copy、retain的话是等价的。如下:

- (void)setXXX:(NSString*)axx

{

      if (_xxx != axx) {

            [_xxx release];

            _xxx = [axx copy];

     }

}

 

拆分下就知道了, 将nil代入(即axx)  对nil进行retain/copy返回仍然是nil 

所以,等价。

转:http://www.cocoachina.com/ask/questions/show/94713

posted @ 2013-12-18 18:19  ygm900  阅读(346)  评论(0)    收藏  举报