S
Self
Self refers to the current instance within its own instance methods.
class Example {
var property = 0
func method() {
self.property = 1
}
}Usage tip: Access properties in iOS class methods; explicit self on watchOS for clarity in extensions.
Set
Set is an unordered collection of unique values.
var colors: Set<String> = ["Red", "Green"]Usage tip: Store unique items in iOS data models; efficient lookups on watchOS for user preferences.
String
String is a sequence of characters.
let greeting: String = "Hello, Swift!"Usage tip: Handle text in SwiftUI labels for iOS; string interpolation on watchOS displays.
Struct
Struct is a value type that encapsulates data and behavior.
struct Point {
var x: Int
var y: Int
}Usage tip: Model immutable data in iOS apps; lightweight structs for watchOS performance.
Switch
Switch evaluates a value against multiple cases.
switch value {
case 1: print("One")
default: print("Other")
}Usage tip: Handle enums in iOS logic; exhaustive switches on watchOS for state management.
SwiftUI
SwiftUI is a framework for building user interfaces declaratively.
import SwiftUI
struct ContentView: View {
var body: some View {
Text("Hello")
}
}Usage tip: Build modern iOS UIs; optimized for watchOS with previews.
T
Throw
Throw propagates an error from a throwing function.
func risky() throws {
throw NetworkError.invalidURL
}Usage tip: Error handling in iOS async calls; throw on watchOS for failed syncs.
Try
Try calls a throwing function, handling potential errors.
do {
try risky()
} catch {}Usage tip: Safe execution in iOS networking; try? for optional results on watchOS.
Tuple
Tuple groups multiple values into a single compound value.
let http404Error = (404, "Not Found")Usage tip: Return multiple values from iOS functions; decompose in watchOS data parsing.
Typealias
Typealias declares an alternative name for an existing type.
typealias AudioSample = UInt16Usage tip: Simplify complex types in iOS code; aliases for watchOS readability.
U
UInt
UInt is an unsigned integer type.
let max: UInt = UInt.maxUsage tip: Positive counts in iOS graphics; bit operations on watchOS.
Unowned
Unowned is a reference that assumes the referenced instance will outlive it.
class Owner {
unowned let dependent: Dependent
}Usage tip: Avoid cycles in iOS delegates; risky but efficient on watchOS.
URL
URL represents a Uniform Resource Locator.
let url = URL(string: "https://example.com")Usage tip: Network requests in iOS; URL handling on watchOS for links.
URLSession
URLSession performs networking tasks.
let session = URLSession.shared
let task = session.dataTask(with: url)Usage tip: Fetch data in iOS backgrounds; shared session on watchOS for efficiency.
V
Var
Var declares a mutable variable.
var changeable = 5Usage tip: State variables in SwiftUI for iOS; mutable props on watchOS.
View
View is a protocol for SwiftUI views.
struct MyView: View {
var body: some View {
Text("View")
}
}Usage tip: Compose UIs in iOS apps; custom views for watchOS.
VStack
VStack arranges child views vertically in SwiftUI.
VStack {
Text("Top")
Text("Bottom")
}Usage tip: Stack elements in iOS forms; vertical layouts on watchOS screens.
W
Weak
Weak is an unowned reference that allows the instance to be deallocated.
weak var delegate: Delegate?Usage tip: Break cycles in iOS closures; memory management on watchOS.
While
While executes a loop as long as a condition is true.
while condition {
// code
}Usage tip: Polling in iOS tasks; avoid infinite loops on watchOS.
WillSet
WillSet is a property observer called before a value is set.
var observed: Int {
willSet { print(newValue) }
}Usage tip: Validate changes in iOS models; observers for watchOS state.
WithAnimation
WithAnimation applies an animation to state changes.
withAnimation {
opacity = 0
}Usage tip: Smooth transitions in iOS SwiftUI; subtle animations on watchOS.
Z
ZStack
ZStack overlays child views in SwiftUI.
ZStack {
Rectangle().fill(Color.red)
Text("Overlay")
}Usage tip: Layer elements in iOS designs; depth effects on watchOS.