Swift Language Features

Swift programming language features: optionals, protocol-oriented programming, generics, async/await, SwiftUI, and memory management (ARC).

  • JSON6,080 B
  • YAML4,494 B · −26%
  • TOON3,711 B · −39%

Swift language features with the version they arrived, a description, syntax and notes: optionals, protocol-oriented programming, generics, result builders, async/await, actors, property wrappers and automatic reference counting.

Use it when

  • You are learning Swift or reading SwiftUI-era code.
  • You need the Swift version in which a feature appeared.

Watch out for

  • Swift evolves quickly; confirm feature availability against the Xcode and Swift version you target.
  • Strict concurrency checking has been rolled out in stages and can change build behavior.

The data

Features

NameIntroducedDescriptionSyntaxNotes
OptionalsSwift 1.0Type-safe way to represent nil values: Optional<T> enum with .none and .some(T)var name: String?; if let unwrapped = name { }Force unwrap (!) crashes on nil; use guard let for early exit
Protocol-Oriented ProgrammingSwift 2.0Define behavior via protocols with default implementations in extensionsprotocol Drawable { func draw() }; extension Drawable { func draw() { /* default */ } }Prefer protocols over inheritance for flexibility and composition
GenericsSwift 1.0Write flexible, reusable code with type parameters and constraintsfunc swap<T>(_ a: inout T, _ b: inout T) { (a, b) = (b, a) }Use where clauses for complex constraints: func process<T: Equatable>(items: [T]) where T: Hashable
Result BuilderSwift 5.4DSL-like syntax for building values ( SwiftUI views, async let groups)@resultBuilder struct HTMLBuilder { static func buildBlock(_ parts: String...) -> String { parts.joined() } }Foundation of SwiftUI's declarative syntax
async/awaitSwift 5.5Structured concurrency with async functions, await keyword, and structured task groupsasync func fetchData() async throws -> Data { try await URLSession.shared.data(from: url) }Replaces callback-based patterns; integrates with actors for thread safety
ActorsSwift 5.5Reference types with actor isolation: only one task accesses mutable state at a timeactor BankAccount { var balance: Double; func deposit(_ amount: Double) async { balance += amount } }Prevents data races; await required when accessing from outside
Property WrappersSwift 5.1Separate property storage logic from definition: @propertyWrapper struct@propertyWrapper struct Lazy<T> { var value: T?; var wrappedValue: T { get set } }Used by @State, @Binding, @ObservedObject in SwiftUI
ARC (Automatic Reference Counting)Swift 1.0Memory management via reference counting; weak/unowned for breaking retain cyclesweak var delegate: DelegateProtocol?; unowned let owner: OwnerNo garbage collector; understand strong/weak/unowned to avoid leaks and crashes

Fields

The shape of this dataset, read from the data itself: every column, its type and a real value. Agents can use this to plan a query without fetching the whole document.

SectionFieldTypeExample
featuresnamestringOptionals
featuresintroducedstringSwift 1.0
featuresdescriptionstringType-safe way to represent nil values: Optional…
featuressyntaxstringvar name: String?; if let unwrapped = name { }
featuresnotesstringForce unwrap (!) crashes on nil; use guard let …

Fetch the same bytes

The static files contain the same reference rows as the API, with no API rate limit. Live metadata, such as view counts, may differ. Use the API for content negotiation; use the static files for a cacheable snapshot.

curl "https://yjtoon.com/api/dataset/swift-language-features?format=toon"
const res = await fetch(
  "https://yjtoon.com/static-data/dataset/swift-language-features.toon"
);
const toon = await res.text();

Rate limit: 120 requests per minute per IP, no key and no signup. API reference →

Topics

  • swift
  • ios
  • optionals
  • protocols
  • generics
  • async-await
  • swiftui
  • arc

Search the library

Search by a topic, title, or keyword.

Start with a collection

Browse all 205 datasets