Naming

August 26, 2019 ยท View on GitHub

General Guidelines

Follow the official Swift API Design Guidelines section on naming.

UI Components

When naming types and instances of views, view controllers, layers, and other components of the user interface, include type information in the name of the type and instance to disambiguate from non-user interface data at usage sites.

Examples

let name: UITextField // ๐Ÿ›‘
name.delegate = self // Unclear at usage.

let nameTextField: UITextField // โœ…
nameTextField.delegate = self // Clear at usage.
final class Settings: UIViewController { } // ๐Ÿ›‘
let settings = Settings() // ๐Ÿ›‘
show(settings, sender: self) // Unclear at usage.

final class SettingsViewController: UIViewController { } // โœ…
let settingsViewController = SettingsViewController() // โœ…
show(settingsViewController, sender: self) // Clear at usage.