- Setup new projects using Liftoff and follow provided directory structure.
- Prefer categories on
Foundationclasses to helper methods. - Prefer string constants to literals when providing keys or key paths to methods.
- Place
#imports into the prefix header (ProjectName-Prefix.pch) only if used in many files. - Place
.xibfiles underResources/Nibsand their associated view files inClasses/Views. - Order
#importstatements alphabetically. - Order
@classdirectives alphabetically. - Order
@propertymodifiers: memory management, atomicity, writability. - Leave out
@propertymodifiers unless needed,nonatomicis the only one needed in most cases. - Prefer strong IBOutlet references.
- Prefer
@classto#importwhen referring to external classes in a public@interface. - Prefer
@propertyto declaring instance variables. - Prefix class names with a 2 or 3 letter project acronym.
- Prefix string constants being used as keys with 'k'.
- Remove
#importstatements forFoundationandUIKitin new project templates. - Separate methods by function using
#pragma mark - <Section Name> - Separate sections into subsections using
#pragma mark <Subsection Name> - Use
@[arrayObject],@{@"key" : value},@(YES or NO), and@5.0literals. - Use
@interface ClassName ()to declare private properties. - Use
lowerCamelCasefor method names. - Use
NSAssertin methods that require the presence of certain arguments. - Write methods using the happy path. Indent the exceptional cases. Keep the optimal case in the left-most column.
- Prefer
enumerateObjectsUsingBlock:when looping through arrays. - Always use braces with control and loop blocks unless it can easily fit on one line.
- Place opening brace for control and loop blocks on same line.
- Prefer
NSInteger,CGFloat, and similar macros overint,float, and other base types. - Prefer Auto Layout for view layouts and constraints.