← iOS Development (Swift) learning path
iOS Development (Swift) · Module 4 of 10

Structs, classes and protocols

Model data with value types, reference types and protocols.

📖 Key ideas

  1. struct is a value type (copied); class is a reference type (shared).
  2. Prefer structs for data models.
  3. Protocols define required properties/methods; types conform to them.
  4. Enums can have associated values.
  5. 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