Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the alternative to excessive use of the dot operator in Obj-C?

See what you think of this line of code:

if ([pickerViewController.picker.bvc.currentResolve.name isEqualToString:message])
  ...

Would you consider this to be excessive use of the dot operator?

If not, I can leave it as-is.

But if so, what's the preferred alternative?

like image 745
Elliot Avatar asked Dec 31 '22 00:12

Elliot


1 Answers

This is more of a Law of Demeter violation than a problem with the dot operator. The "cleaner" way to do this would be to give the object the logic to figure this out itself, so you could do something like

if ([pickerViewController hasPickedName:message])
like image 154
Chuck Avatar answered Jan 05 '23 14:01

Chuck