I have been coding in objective c for a while now, but I still wonder at times if there is a BEST or FASTEST way to do something.
For example let’s say I had a UILabel named myLabel and UIViewController called mainView, what is the FASTEST or BEST way to set it.
Method 1
mainView.myLabel.text = @"String"; //similar to c/c++ style
Method 2
[mainView.myLabel setText:@"String"]; //between c/c++ and obj-c style
Method 3
[[mainView myLabel] setText:@"String"]; //obj-c style
I personally prefer Method 2, because isn’t Method 1 just a shorthand method to access it? Thanks for your help.
All 3 options you listed result in calling the same code (myLabel and setText: methods), so there’s absolutely no performance difference.
So the best way will be to choose whatever single option you like the most and use it consistently through whole your project.