Naming
Last modified on Wed 18 Oct 2023

Basic:

Preferred:

let maximumWidgetCount = 100

class WidgetContainer {
    var widgetButton: UIButton
    let widgetHeightPercentage = 0.85
}

Not preferred:

let MAX_WIDGET_COUNT = 100

class app_widgetContainer {
    var wBut: UIButton
    let wHeightPct = 0.85
}

Functions

Since Swift 3, all function parameters have labels unless you request otherwise by using underscore.

Enumerations

Preferred:

enum CompassPoint {
    case north
    case south
    case east
    case west
}

Not preferred:

enum compassPoint {
    case North
    case South
    case East
    case West
}

Prose

iOS NAMING - JUMP BAR

Example—Prose

Call convertPointAt(column:row:) from your own init implementation.

If you call date(from:), make sure that you provide a string with the "yyyy-MM-dd" format.

You should not call the data source method tableView(_:cellForRowAt:) directly.

Typealias

Example—Typealias:

typealias MimeType: String

func fileURL(with mimeType: MimeType, data: Data) -> URL

Class prefixes

Example:

import SomeModule

let myClass = MyModule.UsefulClass()

This guide is mostly copied from Swift API Design Guidelines, Ray Wenderlich Swift guide, and What's new in Swift 3.0, with some minor changes.