Objective-c style guide

This style guide outline the coding conventions of the iOS team at SQLi Rabat


  • Indent using 4 spaces. Never indent with tabs.
  • Method braces and other function braces (if/else/switch/while) always open on the same line as the statement but close on a new line.

For example:

if (user.isHappy) {
//Do something
else {
//Do something else
  • There should be exactly one blank line between methods to aid in visual clarity and organization.


Variables should be named as descriptively as possible. Single letter variable names should be avoided except in for() loops.

Asterisks indicating pointers belong with the variableNSString *text not NSString* text or NSString * text.


In method signatures there should be a space after the scope (-/+ symbol). There should be a space between the method segments.

For Example:

- (void)setExampleText:(NSString *)text image:(UIImage *)image;


Apple naming conventions should be adhered to wherever possible. Long, descriptive method and variable names are good.

For example:

UIButton *settingsButton;


UIButton *setBut;

Properties and local variables should be camel-case with the leading word being lowercase.

Ternary Operator

The Ternary operator, ? , should only be used when it increases clarity or code neatness. A single condition is usually all that should be evaluated. Evaluating multiple conditions is usually more understandable as an if statement, or refactored into instance variables.

For example:

result = a > b ? x : y;


result = a > b ? x = c > d ? c : d : y;
One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.