【发布时间】:2012-09-25 08:35:02
【问题描述】:
我有几个在其中设置属性的类。
例如一个名为 MyDetailCell 的类,它是 UITableViewCell 的子类。
在其中我有一个类似于...的属性
@property SomeClass *someValue;
最初我使用它并将其存储在 setter 函数中...
- (void)setSomeValue:(SomeClass*)someValue
{
_somValue = someValue;
//do something with the _someValue object like changing text or something...
}
无论如何,我认为我实际上不需要存储发送的值,所以我只是这样做......
- (void)setSomeValue:(SomeClass*)someValue
{
//do something with the _someValue object like changing text or something...
}
然后我更改为刚刚将 setter 传递给子视图的位置。像这样……
- (void)setSomeValue:(SomeClass*)someValue
{
self.someSubView.someValue = someValue;
}
所以现在我不确定要使用什么。我现在根本没有真正保存财产,所以我想我真的不需要它。我不需要访问它来获取值,我只需要设置它。
目前我已将物业原样保留在那里。
- 可以吗?
- 这是不好的做法吗?
- 我应该将其更改为仅使用 setter 方法吗?
- 这样做有什么好处?
【问题讨论】:
标签: iphone ios properties