Skip to content

Instantly share code, notes, and snippets.

@EvgenyKarkan
Last active January 4, 2016 00:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save EvgenyKarkan/8539278 to your computer and use it in GitHub Desktop.
Save EvgenyKarkan/8539278 to your computer and use it in GitHub Desktop.
ObjC conventions

Space vs Tab

Space

- (NSData *)returnSomething 
{
    // uses 4 spaces for indentation
    return data;
}

Tabs

- (NSData *)returnSomething
{
	// uses 1 tab for indentation
	return data;
}

Line Length over 80 characters

Line length is within 80 characters.

/* width is within 80 characters */

Line length is within 100 characters.

/* width is within 100 characters */

Line length is within 120 characters.

/* width is within 120 characters */

Line length is within 150 characters.

/* width is within 150 characters */

Brace Placement (Control Structure)

Curlybrace with one space

if (someInstance != nil) {
    //do stuff
}

while (isTrue) {
    //do stuff
}

switch (type) {
    //do stuff
}

Curlybrace with new line

if (someInstance != nil)
{
    //do stuff
}

while (isTrue) 
{
    //do stuff
}

switch (type) 
{
    //do stuff
}

Curlybrace with no space

if (someInstance != nil){
    //do stuff
}

while (isTrue){
    //do stuff
}

switch (type){
    //do stuff
}

Brace Placement (Methods)

Curlybrace from new line

- (void)clearAllDataWithCompletionBlock:(void (^)(NSString *))block 
{
    //do stuff
}

Curlybrace on same line

- (void)clearAllDataWithCompletionBlock:(void (^)(NSString *))block {
    //do stuff
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment