Coding Rules

Cocoa coding style for the naming.

variableNaming variable should use capitalization on all word expect the first and never '_' ie
RIGHT
BOOL isFirstTimeReading;
int age;

WRONG
BOOL is_first_time_reading;
int Age;
int isFirstTimeReading_ever;

Objective-C Instance variable must be prefixed with _
RIGHT
@interface Object {
	  BOOL _isFirstTimeReading;
	  int _age;
}

WRONG
@interface Object {
	  BOOL isFirstTimeReading;
	  int age;
}

Pointer * must be preceded with a space and with no space after ie
RIGHT
void *pointer;

WRONG
void * pointer;
void* pointer;
void*pointer;

if, switch, and other keyword that are not function but takes parameter should have a space before ()
RIGHT
if (a) {
  ...
}
function();

WRONG
if( a )
if ( a )
if(a)
function ();

{} usage
RIGHT
if (a) {
   ...
}
while (a) {
   ...
}
void function()
{
   ...
}
- (void)functionWithParameter:(BOOL)parameter
{
   ...
}
WRONG
- (void)function {
   ...
}
if (a)
{
   ...
}

Prefer early return ie:
PREFER
if (!a)
    return;

OVER
if (a) {
  ...
  ...
}

Objective C code - Don't call multiply the same method
RIGHT
NSWindow *window = [self window];
NSRect frame = [window frame];
frame.origin.x = 0;
[window setFrame:frame display:NO];
WRONG
NSRect frame = [[self window] frame];
frame.origin.x = 0;
[[self window] setFrame:frame display:NO];