An Opiniated Objective-C Style Guide
Use CamelCase for class names and constants, camelCase for methods and all caps for macros.
The star (*) for pointers should be next to the variable and not the class name (example:
Method signatures should have no extra spaces except after the -/+ (example:
Instance variables should be prepended with an underscore.
Only use #import in .m files unless it’s an import for the base class or a delegate. If you have to use a class name in a method signature, use a forward class declaration (
Sort your imports alphabetically, this helps to prevent duplicated imports. It makes it more obvious if there are any.
Use the name of the class followed by the suffix
Block. Use a noun to describe the block.
For example, a class named TokenManager would could have a typedef named
If many typedefs are used in the same class. Use the name of the class followed by the name of the method that uses it and suffixed by
Block with an informative noun.
This naming convention helps to avoid conflicting typedef definitions.
Prefix all functions in categories with a unique name followed by an underscore to avoid conflicts following an update of the Apple libraries or a pod (example: