Post

Replies

Boosts

Views

Activity

Reply to Using Bindings with (Arrays of) Enumerations
Thank you, @OOPer, this approach works. But I'm wondering whether there are still other solutions. The way I understand how Swift wants you to use value types is to use enums ("sum types") for modeling specialization. The nice thing (in principle) is that access to the associated values is guarded by eg a switch, which provides type safety: you can only access the values in the correct case. By adding computed properties like you suggested to the enum (which would have to be done for all cases), this type safety is lost.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Apr ’21