Skip to content

Coding Style Guide

Jonathan Arbogast edited this page Mar 23, 2015 · 1 revision

This style guide outlines the coding conventions of the JotTouch SDK team. This document will continue to evolve, but at least this is a start.

Apple's Coding Guidelines

Apple has already provided Coding Guidelines for Cocoa and the JotTouch SDK team has adopted these guidelines with the following additions and exceptions.

Exceptions

None so far!

Additions

Braces for All Conditionals

Braces shall be used on all conditionals, even if they are contained to one line.

Example

This is good

if(something) { return 1; }

This is bad

if(something) return 1;

Opening Braces on the Next Line for Methods

Opening braces for methods should follow the Xcode preference of having it on the next line.

Example

This is good

- (void)doSomething 
{

This is bad

- (void)doSomething {

Opening Braces On the Same Line for Conditionals/Loops/etc

Example

This is good

if (followingStandards) {
   [self doItRight];
} else {
   [self getLaughedAt];
}

This is bad

if (followingStandards)
{
   [self doItRight];
} 
else
{
   [self getLaughedAt];
}

##Property Declarations Property declarations shall only use modifiers if they differ from the defaults. The defaults for a property are (strong, atomic, readwrite).

Example

This is good

@property (copy, nonatomic) NSString *myString;

This is also good

@property NSArray *myArray;

This is bad

@property (strong, readwrite) NSArray *myArray;
Clone this wiki locally