← iOS Development (Swift) learning pathiOS Development (Swift) · Module 4 of 10
Structs, classes and protocols
Model data with value types, reference types and protocols.
📖 Key ideas
- struct is a value type (copied); class is a reference type (shared).
- Prefer structs for data models.
- Protocols define required properties/methods; types conform to them.
- Enums can have associated values.
- Extensions add functionality to existing types.
💡 Real-life example: A struct is a photocopy (changes stay with you); a class is a shared Google Doc (everyone sees changes).
structValue type
classReference type
ProtocolBlueprint of requirements
ExtensionAdds features to a type