【发布时间】:2012-10-05 08:26:08
【问题描述】:
我已将UITableViewCell 子类化,在- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier 中我正在设置一些实例变量,如下所示:
_image = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"image.png"]]
我没有使用任何访问器,因为 Apple 建议不要在 init 和 dealloc 中使用访问器。
到目前为止一切顺利。我的问题是在我设置了 _image 之后,我想为图像设置 userInteractionEnabled 为 YES。我应该使用 getter 还是直接使用 ivar?
self.image.userInteractionEnabled = YES;
或者
_image.userInteractionEnabled = YES;
首选哪种风格?
【问题讨论】:
标签: objective-c cocoa init