Swift Enumerations / Swift EnumSwift Enumeration is also known as Swift Enum. It is a data type which consists of set of related values. It is declared in a class and its values are accessed through the instance members of that class. Syntax:Example:Let's take an example to understand it well. Here, we shall an enum named "Connection Status" and see the possible condition using switch statement. Output: Connected In the above example, there are 4 cases: Unknown, Disconnected, Connecting, and Connected. The output is showing as "Connected" as it is set as connected. If you set it "Disconnected", it will show "Disconnected" as output. Example:Output: Disconnected This is how we use enumeration in Swift. Next TopicSwift Structures |