void foo() { // do stuff }
void foo() { // do stuff }
for (int i = 0; i < 10; i++) { // do stuff }
for (int i = 0; i < 10; i++) { // do stuff }
if (timeToGetCoffee) { buyCoffee(&coffee); chugIt(coffee); } else if (timeToGoHome) // comment on else case outtaHere = true;
if (timeToGetCoffee) { buyCoffee(&coffee); chugIt(coffee); // comment on else case } else if (timeToGoHome) { outtaHere = true; } if (timeToGetCoffee) { } else // comment on else case if (timeToGoHome) outtaHere = true;
int myFunction(int arg1, float arg2); void noArgFunction(); // for C++ or Objective-C++ void noArgFunction(void); // for C or Objective-C
int myFunction (int arg1, float arg2); int myFunction( int arg1 , float arg2 ); void noArgFunction ();
0
. In C it should be written as NULL
. In Objective-C, it should be written as nil
if it is being used as a null pointer of type id
or another ObjC object type, otherwise NULL
.bool
(common in C and C++), or just generic true/false values, should be written as true
and false
. Values of the Objective-C BOOL
type should be written as YES
and NO
.// test for true if (foo->isSomething()) { // code } // test for false if (!foo->isSomething()) { // code } // test for non-null if (ptr) { // code } // test for null if (!ptr) { // code } // test for nonzero if (count) { // code } // test for zero if (!count) { // code }
if (foo->isSomething() == true) { // code } if (foo->isSomething() != false) { // code } if (p == NULL) { // code } if (nil != p) { // code } if (count == 0) { // code }
class MyImportantClass;
class My_important_class; class myImportantClass;
int myInt;
int MyInt; int my_int;
#define WBStopButtonTitle() \ NSLocalizedString(@\"Stop\", @\"Stop button title\")
#define WB_STOP_BUTTON_TITLE \ NSLocalizedString(@\"Stop\", @\"Stop button\") #define WBStopButtontitle \ NSLocalizedString(@\"Stop\", @\"Stop button\")
urlVariable myURLAccessor:
uRLVariable myUrlAccessor: