Types for Swift and SwiftUIs
Swift types are the building blocks for modelling data: structs, classes and enums. Structs and enums are value types that are copied on assignment, classes are reference types shared by reference, and Swift manages class memory with automatic reference counting, so cycles between objects must be broken with weak or unowned references.
Stage: Swift Language · Part of the Swift and SwiftUI roadmap · Last reviewed 19 November 2026
What to learn in Types
- Choose between a struct and a class for a given model
- Model states with enums that carry associated values
- Adopt protocols and write extensions to add behaviour
- Explain copy-on-assignment for value types
- Find and fix a retain cycle using weak references
- Use computed properties and property observers
Types interview questions
When should you choose a struct over a class in Swift?
Prefer a struct for simple data models, since it is copied, easy to reason about and thread-friendly. Choose a class when you need shared identity, inheritance, or reference semantics, such as an object that several parts of the app mutate.
How does automatic reference counting cause memory leaks?
ARC frees an object when no strong references remain. If two objects hold strong references to each other, or a closure captures self strongly, the counts never reach zero. Marking one side weak or unowned breaks the cycle.
Where Types fits in the Swift and SwiftUI roadmap
Types belongs to the Swift Language stage (beginner level), which takes about 28 hours. Types and safety.
Other units in this stage
Back to the full Swift and SwiftUI roadmap