Programming in Swift: Functions & Types
Jan 4 2022 Swift 5.5, iOS 15, Xcode 13
Part 5: Protocols & Inheritance
45. Value vs. Reference Types
See course reviews
Update Notes: This course was originally recorded in 2019. It has been reviewed and all content and materials updated as of October 2021.
Before I wrap up this course, I want to touch on a few lingering questions you might have about all of these named types.
Value vs. Reference
[Slide 01] A common big question is whether to use a structure or a class. This might also be phrased like “Should I use a value type or a reference type?”.
Sometimes you don’t actually have a choice. If you’re extending the behavior of code you don’t own, you may have to subclass. In that button example, it’s possible Button is part of a framework you’re using, and there’s no way you can modify or extend the source code to fit your needs.