In Google's Objective-C Style guide which is follow by many people , Google says
Class member variables have trailing underscores
Why? Is there any good reason for doing this? I found apple usually name an ivar when beginning underscore.
I prefer trailing underscores because if I have:
int test_;
I can type 't' and it will appear in the code completion immediately.
With
int _test;
I have to type '_t' to get to the T's in code completion.
Whether that's true or not, not sure, but that's what I've convinced myself of.
Heavy users of Core Data will have also noticed that Core Data attributes cannot begin with non-alpha characters. If you want to name ivars consistently across your app and various projects, this is another reason to append, rather than prepend, your ivars with an underscore.
If you're not using Core Data a lot, or you don't have OCD tendencies towards consistency in naming conventions, then whatever works best for you is probably the right answer.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With