开发者

Is (retain) required if setter is manually implemented?

I would like to know what effect (if any) does the retain in the following property declaration have. The manually implemented setter is retaining the variable.

Interface:

@property (nonatomic, retain, setter=s开发者_开发知识库etIncident:) Incident * incident;

Implementation:

- (void)setIncident:(CSIncident *)newIncident  
{  
    if (incident != newIncident)  
    {  
        [incident release];  
        incident = [newIncident retain];  
    }  
}


It doesn't have much value since you're manually controlling the set behavior and retaining it manually.

The only (very minimal) value would be readability to understand the behavior when you're just looking at the header and less churn if you remove the manual implementation (but you already have to remove setter=).

In your question you also have a mismatch between setDog and setIncident

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜