-
Book Overview & Buying
-
Table Of Contents
Swift 2 Design Patterns
By :
The memento pattern will be the last pattern that we will discover together. You will see that this pattern is really interesting to work with and has many uses.
The role of the memento pattern is to capture an object's internal state and save it externally so that it can be restored later without breaking the encapsulation of this object.
The generic UML class diagram is defined as the following:

The following are the participants of the memento pattern:
Memento: This is the class for the objects that saved the internal states of origin objects (or part of this state), such as the introduction of the fact that the saving of a state can be made independent of the object itself. The memento has two interfaces:
A complete interface for Originator objects that permit access to everything that needs to be saved or restored
A narrow interface to the caretaker that can keep and pass on the memento references, but no more
Originator: This is the object class...
Change the font size
Change margin width
Change background colour