Sitemap
Kirill Chuyanov

Kirill Chuyanov

[100% Follow-Back] Experienced iOS developer and Flutter enthusiast. Passionate about functional programming and elegant software design. Sharing tech insights.

Member-only story

Memento Pattern [Swift]

8 min readAug 14, 2025
Press enter or click to view image in full size
Photo by Teo D on Unsplash

Recently, I came across a post on LinkedIn with a snippet on how to implement the Memento Pattern:

LinkedIn post on Memento Pattern implementation example

A mere glimpse of this snippet was enough to realize that this implementation is far from being the Memento Pattern.

Through building a simple macOS text editor app, we will figure out:

  • What is the Memento Pattern?
  • What pattern comes along with it?
  • How to implement it properly?

I am a fan of the GoF book, but there is a lovely website with examples in many languages that contains all the patterns from the book and more.

What is the Memento Pattern

The primary purpose of the pattern is to encapsulate an object’s internal state, allowing it to be restored later without exposing its implementation details.

The pattern consists of:

  • Memento
  • Originator
  • Caretaker

--

--

Kirill Chuyanov
Kirill Chuyanov

Written by Kirill Chuyanov

[100% Follow-Back] Experienced iOS developer and Flutter enthusiast. Passionate about functional programming and elegant software design. Sharing tech insights.