> Design Patterns > Memento > Memento Design Pattern In Swift

Memento Design Pattern In Swift

Memento design pattern in Swift to capture the state of an object without violating encapsulation, so that if required then it can be returned to its previous state.


Memento design pattern In Swift

Output

The state value is : 1
The state value is : 0
Going to previous state
The state value is : 1


Suresh Kumar Srivastava is founder of online learning site coursegalaxy.com and author of popular books C In Depth, Data Structures Through C In Depth. He has 18+ years experience in industry and worked on architecture and design of multiple products. This article Memento Design Pattern In Swift is from his Design Patterns course.