The Adapter Design Pattern in Swift

Collaborate together!

Steven Curtis
3 min readMay 28, 2021
Who is this be-hatted person?

Difficulty: Beginner | Easy | Normal | Challenging

This article has been developed using Xcode 11.5, and Swift 5.2.4

Prerequisites:

  • You will be expected to be aware how to make a Single View Application in Swift.
  • This article references use of the Playground, although you could translate the tests to that Single View Application

Terminology

Adapter Pattern: allows the interface of an existing class to be used as another interface

Design Pattern: a general, reusable solution to a commonly occurring problem

Adapters allow one thing to work with another, like when a European electrical applicance needs to be used in the Americas (you would need to change the pins and the voltage to enable the appliance to work).

In software engineering the adapter pattern allows the interface of an existing class to be used as another interface.

--

--