# \#enums

**URL:** https://forums.swift.org/tag/enums/170.md

[Latest](https://forums.swift.org/latest.md) · [Categories](https://forums.swift.org/categories.md) · [Tags](https://forums.swift.org/tags.md)

---

## [How to get the name strings for an enumeration type's singular cases](https://forums.swift.org/t/how-to-get-the-name-strings-for-an-enumeration-types-singular-cases/88693)

<div class="topic-metadata">

**Author:** [@CTMacUser](https://forums.swift.org/u/CTMacUser)\
**Replies:** 1\
**Last updated:** [August 1, 2026, 12:00am UTC](https://forums.swift.org/t/how-to-get-the-name-strings-for-an-enumeration-types-singular-cases/88693 "2026-08-01T00:00:53Z")

</div>

Several posts here mentioned how Mirror can get the full name parts of enumeration cases with payloads, but those techniques don't work for singular cases. Yes, enum types can automatically provide String renditions, but…

---

## [Can enums derived from BitwiseCopyable primitives be implicitly BitwiseCopyable](https://forums.swift.org/t/can-enums-derived-from-bitwisecopyable-primitives-be-implicitly-bitwisecopyable/87460)

<div class="topic-metadata">

**Author:** [@blindspotbounty](https://forums.swift.org/u/blindspotbounty)\
**Replies:** 6\
**Last updated:** [June 18, 2026, 11:38pm UTC](https://forums.swift.org/t/can-enums-derived-from-bitwisecopyable-primitives-be-implicitly-bitwisecopyable/87460 "2026-06-18T23:38:14Z")

</div>

Currently, if I have enum: enum Foo: Int8 { case a case b } It won't implicitly derive BitwiseCopyable and I should explicitly set it everywhere: enum Foo: Int8, BitwiseCopyable { case a case b } I wo…

---

## [What are associated value labels for, when disregarding values?](https://forums.swift.org/t/what-are-associated-value-labels-for-when-disregarding-values/86447)

<div class="topic-metadata">

**Author:** [@Danny](https://forums.swift.org/u/Danny)\
**Replies:** 0\
**Last updated:** [May 3, 2026, 2:36am UTC](https://forums.swift.org/t/what-are-associated-value-labels-for-when-disregarding-values/86447 "2026-05-03T02:36:09Z")

</div>

They don't seem to be able to disambiguate, so, are they just for clarity in the situations where switch is actually functional? Is the lack of disambiguability with if just the same bug as switch, even though it compile…

---

## [Handling future cases of enums in libraries without binary stability concerns](https://forums.swift.org/t/handling-future-cases-of-enums-in-libraries-without-binary-stability-concerns/32026)

<div class="topic-metadata">

**Author:** [@broadway\_lamb](https://forums.swift.org/u/broadway_lamb)\
**Replies:** 11\
**Last updated:** [April 6, 2026, 7:39pm UTC](https://forums.swift.org/t/handling-future-cases-of-enums-in-libraries-without-binary-stability-concerns/32026 "2026-04-06T19:39:18Z")

</div>

Hi swift-evolution, I'd like to pitch a proposal that is basically SE-0192, but for library authors that don't care about binary stability. I've complained about the problem earlier, and now I'd like to suggest a solut…

---

## [\`@available(\*, unavailable)\` enum cases and switch exhaustiveness](https://forums.swift.org/t/available-unavailable-enum-cases-and-switch-exhaustiveness/85471)

<div class="topic-metadata">

**Author:** [@devioustree](https://forums.swift.org/u/devioustree)\
**Replies:** 3\
**Last updated:** [March 21, 2026, 12:52pm UTC](https://forums.swift.org/t/available-unavailable-enum-cases-and-switch-exhaustiveness/85471 "2026-03-21T12:52:30Z")

</div>

I stumbled across something unexpected with @available(\*, unavailable) on enum cases and wanted to check whether this is intentional or not. Given this somewhat philosophical enum: enum Availability { @available(\*,…

---

## [RawRepresentable Enum - literal requirement](https://forums.swift.org/t/rawrepresentable-enum-literal-requirement/85386)

<div class="topic-metadata">

**Author:** [@blindspotbounty](https://forums.swift.org/u/blindspotbounty)\
**Replies:** 9\
**Last updated:** [March 18, 2026, 1:59pm UTC](https://forums.swift.org/t/rawrepresentable-enum-literal-requirement/85386 "2026-03-18T13:59:31Z")

</div>

I was looking the way to use custom type with RawRepresentable enums. And seems it is possible if they can be instantiated from literals. I looked at couple of topics around raw representable enums: Enum case value m…

---

## [Shorthand for checking equality against multiple enum cases](https://forums.swift.org/t/shorthand-for-checking-equality-against-multiple-enum-cases/83756)

<div class="topic-metadata">

**Author:** [@marlonjames71](https://forums.swift.org/u/marlonjames71)\
**Replies:** 33\
**Last updated:** [January 19, 2026, 10:36pm UTC](https://forums.swift.org/t/shorthand-for-checking-equality-against-multiple-enum-cases/83756 "2026-01-19T22:36:40Z")

</div>

I’ve noticed that I often need to check if a value matches one of several enum cases. While Swift is generally very expressive, this specific pattern feels a bit repetitive. I’m curious if there has ever been a discussio…

---

## [Edge case enum](https://forums.swift.org/t/edge-case-enum/68181)

<div class="topic-metadata">

**Author:** [@tera](https://forums.swift.org/u/tera)\
**Replies:** 35\
**Last updated:** [December 21, 2025, 3:12am UTC](https://forums.swift.org/t/edge-case-enum/68181 "2025-12-21T03:12:11Z")

</div>

Found this edge case scenario: enum E: String { case a = "\\u{00c5}" // Å precomposed form case b = "A\\u{030A}" // Å decomposed form } Here I am using enumeration constants with "equal" (according to str…

---

## [Public enum inaccessible due to @\_spi isolation level error](https://forums.swift.org/t/public-enum-inaccessible-due-to-spi-isolation-level-error/82499)

<div class="topic-metadata">

**Author:** [@Drejzer](https://forums.swift.org/u/Drejzer)\
**Replies:** 1\
**Last updated:** [October 6, 2025, 12:29pm UTC](https://forums.swift.org/t/public-enum-inaccessible-due-to-spi-isolation-level-error/82499 "2025-10-06T12:29:00Z")

</div>

For context I’m working on a wrapper for a C++ library. I havepublic enum PMXEventSubscriptionRequest: Hashable, Sendable used for event registration. Well, event registration takes a struct that has that enum, a string…

---

## [\[Pre-Pitch\] Disconnected Properties and Variables, and Opaque enums](https://forums.swift.org/t/pre-pitch-disconnected-properties-and-variables-and-opaque-enums/81355)

<div class="topic-metadata">

**Author:** [@metaphorce42](https://forums.swift.org/u/metaphorce42)\
**Replies:** 12\
**Last updated:** [July 31, 2025, 9:25pm UTC](https://forums.swift.org/t/pre-pitch-disconnected-properties-and-variables-and-opaque-enums/81355 "2025-07-31T21:25:00Z")

</div>

Currently in Swift 6.2, you cannot send an object out of an actor or Task if it has been bound to a property or captured. Also you cannot send a non-Sendable object from a synchronous context into an asynchronous context…

---

## [Automatically Synthesize Identifiable Conformance for Enums](https://forums.swift.org/t/automatically-synthesize-identifiable-conformance-for-enums/81002)

<div class="topic-metadata">

**Author:** [@rlziii](https://forums.swift.org/u/rlziii)\
**Replies:** 22\
**Last updated:** [July 15, 2025, 6:48pm UTC](https://forums.swift.org/t/automatically-synthesize-identifiable-conformance-for-enums/81002 "2025-07-15T18:48:33Z")

</div>

Many types in Swift, namely value types, benefit from the ability to automatically conform to certain protocols if they satisfy certain conditions. For example, if an enum in Swift either has no associated values or has…

---

## [Codable enum's associated value is unexpectedly using positional name](https://forums.swift.org/t/codable-enums-associated-value-is-unexpectedly-using-positional-name/63569)

<div class="topic-metadata">

**Author:** [@calvin](https://forums.swift.org/u/calvin)\
**Replies:** 23\
**Last updated:** [June 20, 2025, 11:57am UTC](https://forums.swift.org/t/codable-enums-associated-value-is-unexpectedly-using-positional-name/63569 "2025-06-20T11:57:42Z")

</div>

I have an enum something like: enum Response: Codable { case error(message: String) case hello(username: String, version: String) case list(\[String: \[String: ListUser\]\]) // struct ListUser is Codable and def…

---

## [Constexpr is not imported when declared within a namespace](https://forums.swift.org/t/constexpr-is-not-imported-when-declared-within-a-namespace/79711)

<div class="topic-metadata">

**Author:** [@Drejzer](https://forums.swift.org/u/Drejzer)\
**Replies:** 0\
**Last updated:** [May 6, 2025, 11:41am UTC](https://forums.swift.org/t/constexpr-is-not-imported-when-declared-within-a-namespace/79711 "2025-05-06T11:41:00Z")

</div>

When a constexpr appears inside a namespace it does not get exported to Swift, but when it is declared outside any namespaces, it is available. For example namespace namespace\_test{ constexpr int TEST = 44; } constexpr…

---

## [LLDB prints wrong UUID value](https://forums.swift.org/t/lldb-prints-wrong-uuid-value/78622)

<div class="topic-metadata">

**Author:** [@AlexBlack559](https://forums.swift.org/u/AlexBlack559)\
**Replies:** 3\
**Last updated:** [March 18, 2025, 9:26pm UTC](https://forums.swift.org/t/lldb-prints-wrong-uuid-value/78622 "2025-03-18T21:26:44Z")

</div>

LLDB prints the wrong UUID value when unwrapping it as an associated value within a switch‑case statement. let's consider following example: enum MyEnum { case firstCase(UUID) } let myEnum = MyEnum.firstCase(UUID(…

---

## [Swift enum with a default case](https://forums.swift.org/t/swift-enum-with-a-default-case/77882)

<div class="topic-metadata">

**Author:** [@swifto](https://forums.swift.org/u/swifto)\
**Replies:** 1\
**Last updated:** [February 15, 2025, 1:28am UTC](https://forums.swift.org/t/swift-enum-with-a-default-case/77882 "2025-02-15T01:28:17Z")

</div>

Is there a way to provide a default case enum with argument. The output of the below code is Example Optional("admin") Example Optional(main.UserType.userDefault)) If I print example?.rawValue I get userDefault, howev…

---

## [Dilemma about enum with associated values and protocols](https://forums.swift.org/t/dilemma-about-enum-with-associated-values-and-protocols/77118)

<div class="topic-metadata">

**Author:** [@jeudesprits](https://forums.swift.org/u/jeudesprits)\
**Replies:** 9\
**Last updated:** [January 12, 2025, 3:04pm UTC](https://forums.swift.org/t/dilemma-about-enum-with-associated-values-and-protocols/77118 "2025-01-12T15:04:37Z")

</div>

I can't resolve the dilemma of whether to use enums with associated values, or to use protocols, for cases where types are loosely related and there will be little or no constraints in the protocol itself. The important …

---

## [Enum extension](https://forums.swift.org/t/enum-extension/34956)

<div class="topic-metadata">

**Author:** [@Frery](https://forums.swift.org/u/Frery)\
**Replies:** 4\
**Last updated:** [December 27, 2024, 6:05am UTC](https://forums.swift.org/t/enum-extension/34956 "2024-12-27T06:05:26Z")

</div>

Hi, there~ What can i do for this below? I wanna to expand case options. Any solutions? Thx for ur attention.

---

## [Compiler hang on consuming in noncopyable enum with URL in associated value?](https://forums.swift.org/t/compiler-hang-on-consuming-in-noncopyable-enum-with-url-in-associated-value/74282)

<div class="topic-metadata">

**Author:** [@EthanLS](https://forums.swift.org/u/EthanLS)\
**Replies:** 2\
**Last updated:** [August 30, 2024, 9:50pm UTC](https://forums.swift.org/t/compiler-hang-on-consuming-in-noncopyable-enum-with-url-in-associated-value/74282 "2024-08-30T21:50:53Z")

</div>

Am I doing something wrong here? (e.g. Is there some extra syntax I'm supposed to provide to hint the compiler so it can complete?) Or should I file a bug somewhere? Given: enum MyEnum: ~Copyable{ case nothing …

---

## [\[Enum\] Allow to init/assign a case with another case of the same enum (for aliases)](https://forums.swift.org/t/enum-allow-to-init-assign-a-case-with-another-case-of-the-same-enum-for-aliases/29043)

<div class="topic-metadata">

**Author:** [@elect86](https://forums.swift.org/u/elect86)\
**Replies:** 16\
**Last updated:** [August 4, 2024, 12:22pm UTC](https://forums.swift.org/t/enum-allow-to-init-assign-a-case-with-another-case-of-the-same-enum-for-aliases/29043 "2024-08-04T12:22:42Z")

</div>

As titled, I'd like to being able to type enum MouseButton: Int { case \_1, \_2, \_3, \_4, \_5, \_6, \_7, \_8 case last = \_8, left = \_1, right = \_2, middle = \_3 }

---

## [Suppressing uninhabited enum warnings?](https://forums.swift.org/t/suppressing-uninhabited-enum-warnings/72487)

<div class="topic-metadata">

**Author:** [@stephencelis](https://forums.swift.org/u/stephencelis)\
**Replies:** 3\
**Last updated:** [June 20, 2024, 11:04pm UTC](https://forums.swift.org/t/suppressing-uninhabited-enum-warnings/72487 "2024-06-20T23:04:31Z")

</div>

I have a macro that generates code that involves embedding a value in a case, but this can lead to a warning when the value is an uninhabited enum, like Never. Effectively, it produces this warning: enum Bar {} enum Foo…

---

## [Best approach to enum with associated value common across all cases](https://forums.swift.org/t/best-approach-to-enum-with-associated-value-common-across-all-cases/72577)

<div class="topic-metadata">

**Author:** [@gahms](https://forums.swift.org/u/gahms)\
**Replies:** 11\
**Last updated:** [June 18, 2024, 6:39pm UTC](https://forums.swift.org/t/best-approach-to-enum-with-associated-value-common-across-all-cases/72577 "2024-06-18T18:39:18Z")

</div>

What is the best approach when we have an enum where we want an associated value common across all enum cases? Obvious solution is to wrap it in a struct but I wonder if there is a better approach. Example enum Elemen…

---

## [Binding enums in a switch case](https://forums.swift.org/t/binding-enums-in-a-switch-case/72324)

<div class="topic-metadata">

**Author:** [@Alc](https://forums.swift.org/u/Alc)\
**Replies:** 15\
**Last updated:** [June 10, 2024, 2:33am UTC](https://forums.swift.org/t/binding-enums-in-a-switch-case/72324 "2024-06-10T02:33:20Z")

</div>

Purely motivated by academic reasons, is there a way I can avoid the if let binding and do something like the second (invalid) snippet? This does what I want enum SomeEnum: String { case a, b, c } for i in \["a", "bb",…

---

## [Swift \> Objc Enum interop](https://forums.swift.org/t/swift-objc-enum-interop/71728)

<div class="topic-metadata">

**Author:** [@brustolin](https://forums.swift.org/u/brustolin)\
**Replies:** 3\
**Last updated:** [May 10, 2024, 6:09pm UTC](https://forums.swift.org/t/swift-objc-enum-interop/71728 "2024-05-10T18:09:56Z")

</div>

Not sure if the right place to ask this, but someone may have a clue. Scenario: Working on an old Objc Framework, trying to slowly move to Swift. The problem: I have a swift enum that is used as an objc class property. …

---

## [Is it possible to have multiple statements in a branch of a switch statement?](https://forums.swift.org/t/is-it-possible-to-have-multiple-statements-in-a-branch-of-a-switch-statement/70101)

<div class="topic-metadata">

**Author:** [@rishflab](https://forums.swift.org/u/rishflab)\
**Replies:** 6\
**Last updated:** [February 18, 2024, 12:21pm UTC](https://forums.swift.org/t/is-it-possible-to-have-multiple-statements-in-a-branch-of-a-switch-statement/70101 "2024-02-18T12:21:55Z")

</div>

How can I have multiple statements in a case arm? let base\_pose = switch lowerBodyState { case let .idle(entered): assets.get\_anim(name: "idle").pose(time: now - entered) case let .moving(entered): …

---

## [An incomplete CaseIterable conformance](https://forums.swift.org/t/an-incomplete-caseiterable-conformance/69419)

<div class="topic-metadata">

**Author:** [@tera](https://forums.swift.org/u/tera)\
**Replies:** 2\
**Last updated:** [January 13, 2024, 5:11pm UTC](https://forums.swift.org/t/an-incomplete-caseiterable-conformance/69419 "2024-01-13T17:11:29Z")

</div>

Could anything bad happen if my enum's custom CaseIterable conformance doesn't list all possible values?

---

## [Enum with associated values and default values/raw values?](https://forums.swift.org/t/enum-with-associated-values-and-default-values-raw-values/69033)

<div class="topic-metadata">

**Author:** [@iJKTen](https://forums.swift.org/u/iJKTen)\
**Replies:** 2\
**Last updated:** [December 16, 2023, 11:34pm UTC](https://forums.swift.org/t/enum-with-associated-values-and-default-values-raw-values/69033 "2023-12-16T23:34:50Z")

</div>

I am trying to build a JSON parser as an exercise and I was thinking what if I have an enum called Token with values like enum Token: String { case OpenCurly = "{" case CloseCurly = "}" case OpenArray = "\[" …

---

## [Why this enum is strange?](https://forums.swift.org/t/why-this-enum-is-strange/68990)

<div class="topic-metadata">

**Author:** [@brenoma](https://forums.swift.org/u/brenoma)\
**Replies:** 9\
**Last updated:** [December 14, 2023, 8:36pm UTC](https://forums.swift.org/t/why-this-enum-is-strange/68990 "2023-12-14T20:36:02Z")

</div>

Anyone can help me, Ive just starting to study swift, and now doing the iOS App Dev Tutorial (Scrumdinger), so, in some part of the tutorial Ive created this enum, and it didn't get the colors when used the var mainColor…

---

## [Swift Macros: Adding an enum case with an associated value produces incorrect results](https://forums.swift.org/t/swift-macros-adding-an-enum-case-with-an-associated-value-produces-incorrect-results/68674)

<div class="topic-metadata">

**Author:** [@skyler-cricut](https://forums.swift.org/u/skyler-cricut)\
**Replies:** 3\
**Last updated:** [December 4, 2023, 7:50pm UTC](https://forums.swift.org/t/swift-macros-adding-an-enum-case-with-an-associated-value-produces-incorrect-results/68674 "2023-12-04T19:50:43Z")

</div>

Reproduced in Xcode versions 15.0.1 and 15.1 beta 3. If a Macro adds an enum case with an associated value, other cases are transformed at runtime. In the example below, the case foo is translated into the Macro-generat…

---

## [Why is CaseIterable faster then a Set](https://forums.swift.org/t/why-is-caseiterable-faster-then-a-set/68079)

<div class="topic-metadata">

**Author:** [@Kilian](https://forums.swift.org/u/Kilian)\
**Replies:** 4\
**Last updated:** [October 26, 2023, 2:48pm UTC](https://forums.swift.org/t/why-is-caseiterable-faster-then-a-set/68079 "2023-10-26T14:48:47Z")

</div>

// V1 enum VaccineCodeSet: String { case covidModerna = "207" case covidBioNTech = "208" case covidAstraZeneca = "210" case covidNovax = "211" case covidJohnson = "212" case covidValneva = "213" …

---

## [\[Pitch\] \`Enum\`-like cases within protocols](https://forums.swift.org/t/pitch-enum-like-cases-within-protocols/67958)

<div class="topic-metadata">

**Author:** [@Sid-MB](https://forums.swift.org/u/Sid-MB)\
**Replies:** 2\
**Last updated:** [October 23, 2023, 8:58pm UTC](https://forums.swift.org/t/pitch-enum-like-cases-within-protocols/67958 "2023-10-23T20:58:25Z")

</div>

Enum-like cases within Protocols Swift already supports using enum-like syntax in protocols, for example: import SwiftUI extension PrimitiveButtonStyle where Self == BorderlessButtonStyle { public static var borderle…

[Next page](https://forums.swift.org/tag/enums/170.md?match_all_tags=true&page=1&tags%5B%5D=enums)
