api: YAML JSON TOON Database version: 1.0.0 format: json dataset: id: 51 slug: swift-language-features title: Swift Language Features description: "Swift programming language features: optionals, protocol-oriented programming, generics, async/await, SwiftUI, and memory management (ARC)." summary: "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_when[2]: You are learning Swift or reading SwiftUI-era code.,You need the Swift version in which a feature appeared. caveats[2]: 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. related[4]: language-comparison-2026,csharp-dotnet-features,rust-language-features,behavioral-design-patterns category: Programming Languages category_slug: programming-languages tags: "swift,ios,optionals,protocols,generics,async-await,swiftui,arc" view_count: 0 created_at: 1778695229 updated_at: 1778695229 entry_count: 8 fields[5]{section,field,type,example}: features,name,string,Optionals features,introduced,string,Swift 1.0 features,description,string,"Type-safe way to represent nil values: Optional…" features,syntax,string,"var name: String?; if let unwrapped = name { }" features,notes,string,Force unwrap (!) crashes on nil; use guard let … data: features[8]{name,introduced,description,syntax,notes}: Optionals,Swift 1.0,"Type-safe way to represent nil values: Optional 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 Programming,Swift 2.0,Define behavior via protocols with default implementations in extensions,"protocol Drawable { func draw() }; extension Drawable { func draw() { /* default */ } }",Prefer protocols over inheritance for flexibility and composition Generics,Swift 1.0,"Write flexible, reusable code with type parameters and constraints","func swap(_ a: inout T, _ b: inout T) { (a, b) = (b, a) }","Use where clauses for complex constraints: func process(items: [T]) where T: Hashable" Result Builder,Swift 5.4,"DSL-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/await,Swift 5.5,"Structured concurrency with async functions, await keyword, and structured task groups","async func fetchData() async throws -> Data { try await URLSession.shared.data(from: url) }",Replaces callback-based patterns; integrates with actors for thread safety Actors,Swift 5.5,"Reference types with actor isolation: only one task accesses mutable state at a time","actor BankAccount { var balance: Double; func deposit(_ amount: Double) async { balance += amount } }",Prevents data races; await required when accessing from outside Property Wrappers,Swift 5.1,"Separate property storage logic from definition: @propertyWrapper struct","@propertyWrapper struct Lazy { var value: T?; var wrappedValue: T { get set } }","Used by @State, @Binding, @ObservedObject in SwiftUI" ARC (Automatic Reference Counting),Swift 1.0,Memory management via reference counting; weak/unowned for breaking retain cycles,"weak var delegate: DelegateProtocol?; unowned let owner: Owner",No garbage collector; understand strong/weak/unowned to avoid leaks and crashes