Hey, I have just reduced the price for all products. Let's prepare our programming skills for the post-COVID era. Check it out »
State

State in Swift

State is a behavioral design pattern that allows an object to change the behavior when its internal state changes.

The pattern extracts state-related behaviors into separate state classes and forces the original object to delegate the work to an instance of these classes, instead of acting on its own.

Usage of the pattern in Swift

Complexity:

Popularity:

Usage examples: The State pattern is commonly used in Swift to convert massive switch-base state machines into the objects.

Identification: State pattern can be recognized by methods that change their behavior depending on the objects’ state, controlled externally.

State in Other Languages

Design Patterns: State in Java Design Patterns: State in C# Design Patterns: State in C++ Design Patterns: State in PHP Design Patterns: State in Python Design Patterns: State in Ruby Design Patterns: State in TypeScript Design Patterns: State in Go