Capitalization
suggest changeTypes & Protocols
Type and protocol names should start with an uppercase letter.
Example:
protocol Collection {}
struct String {}
class UIView {}
struct Int {}
enum Color {}
Everything else…
Variables, constants, functions and enumeration cases should start with a lowercase letter.
Example:
let greeting = "Hello"
let height = 42.0
enum Color {
case red
case green
case blue
}
func print(_ string: String) {
...
}
Camel Case:
All naming should use the appropriate camel case. Upper camel case for type/protocol names and lower camel case for everything else.
Upper Camel Case:
protocol IteratorType { ... }
Lower Camel Case:
let inputView = ...
Abbreviations
Abbreviations should be avoided unless commonly used (e.g. URL, ID). If an abbreviation is used, all letters should have the same case.
Example:
let userID: UserID = ...
let urlString: URLString = ...
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents