As the title indicate, how should I name the variables that reference GUI elements.
buttonStartTest
startTestButton
btnStartTest
startTestBtn
or should I use startTest?
I like this one: startTestButton, but I don’t know what the convention is, and what’s a good way to name them. I know the Hungarian notation is discouraged, but on GUI it is “allowed”.
I also wonder what is the prefered way to name variables referencing viewcontrollers? If you have a variable referencing a UINavigationController, I name them myReferenceNVC, should I just use myReferenceinstead?
There’s no reason to shorten
buttontobtn, it clearly defies the verbose platform conventions andbuttonis easier to read, so you can throw those out straight away. Apple tends to append types rather than prepend them, sofooButtonis preferable tobuttonFoo– cf.FooViewController,FooAppDelegate, etc.I started out not appending a type at all, but I found that instance variables that weren’t UI elements often conflicted with names for UI elements, so I wouldn’t recommend leaving
buttonout altogether.For more information, see Coding Guidelines for Cocoa – Apple do have guidance for this.