I've been reading about law of Demeter and I would like to know how to solve this traversing model properties problem that I see a lot on Objective-C. I know that there is a similar question but in this case I'm not calling a method from the last property that do some calculations, instead, I'm just setting values (Ok, I know that getter are methods but my intention here is just to get the value, not to change the state of some object).
For example:
self.priceLabel.text = self.media.ad.price.value; Should I change that for something like:
self.priceLabel.text = [self.media adPriceValue]; and inside the Media.m
- (NSString *)adPriceValue { return [self.ad priceValue]; } and inside the Ad.m
- (NSString *)priceValue { return [self.price value]; } Is that a good solution? Or Am I creating unnecessary methods?