I have subclassed UITableViewCell and in the - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier I’m setting some instance variables like so:
_image = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"image.png"]]
I’m not using any accessor because Apple recommends not using accessors in init and dealloc.
So far so good. My question is after I’ve set the _image I want to set userInteractionEnabled to YES for the image. Should I do it with the getter or should I use the ivar directly?
self.image.userInteractionEnabled = YES;
Or
_image.userInteractionEnabled = YES;
Which style is preferred of using?
The recommendation still holds: use the ivar directly in init. If you ever implement a custom accessor on that property (now or later, here or when subclassing), you might be in trouble.