Use a Base Class or a Protocol In Swift?
One of those old questions
Before we start
Difficulty: Beginner | Easy | Normal | Challenging
This article has been developed using Xcode 12.5, and Swift 5.
Prerequisites:
- You will be expected to be aware of how to make a Single View Application in Swift
Terminology
Base Class: A class, in an object-oriented programming language, from which other classes are derived
Class: An object that defines properties and methods in common
Protocol: A blueprint on methods, properties and requirements to suit a piece of functionality
Reference type: A pointer to a variable or object
Value types: Where a value is stored as the actual value of the item
The Project
You are designing an Instagram — like social media Application. The user is able to post audio, video or text messages to their timeline.
The Base Class Implementation
As part of this project, we have friends that are represented by the following User class: