swift
Swift Style Guide
Naming
-
Use UpperCamelCase for type and protocol names, and lowerCamelCase for everything else.
-
Name booleans like
isSpaceship,hasSpacesuit, etc. This makes it clear that they are booleans and not other types. -
Acronyms in names (
ID,URL, etc) should be all-caps except when it’s the start of a name that would otherwise be lowerCamelCase, in which case it should be uniformly lower-cased. -
Event-handling functions should be named like past-tense sentences (e.g.
didTap, nothandleTap). The subject can be omitted if it's not needed for clarity. -
Avoid Objective-C-style acronym prefixes. This is not needed to avoid naming conflicts in Swift.
Style
-
Don't include types where they can be easily inferred.
-
Prefer letting the type of a variable or property be inferred from the right-hand-side value rather than writing the type explicitly on the left-hand side.