相关疑难解决方法(0)

为什么我不应该使用getter来释放objective-c中的属性?

有人告诉我一个老乡的StackOverflow用户是释放特性时,我不应该使用的getter方法:

@property(nonatmic, retain) Type* variable;
@synthesize variable;

// wrong
[self.variable release]; 

// right
[variable release]; 
Run Code Online (Sandbox Code Playgroud)

他没有详细解释原因.它们看起来和我一样.我的iOS书说,物业上的吸气器将如下所示:

- (id)variable {
    return variable;
}
Run Code Online (Sandbox Code Playgroud)

所以这不是意味着[self variable],self.variable并且variable都是一样的吗?

objective-c ios

17
推荐指数
3
解决办法
1039
查看次数

标签 统计

ios ×1

objective-c ×1