title: Picker for optional data type in observable class in SwiftUI?
body: <p>I have a very similar problem to <a href="https://stackoverflow.com/questions/59348093/picker-for-optional-data-type-in-swiftui">Picker for optional data type in SwiftUI?</a>.</p>
  <p>The difference is, that I'm referencing an optional in an obserable class.</p>
  <p>My code looks like:</p>
  <pre><code>enum Flavor: String, CaseIterable, Identifiable {
      case chocolate
      case vanilla
      case strawberry
  
      var id: String { self.rawValue }
  }
  class cl1: ObservableObject {
      @Published var fl: Flavor?
  }
  struct ContentView: View {
      @State private var selectedFlavor: cl1 = cl1()
      var body: some View {
  
          Picker(&quot;Flavor&quot;, selection: $selectedFlavor.fl) {
              Text(&quot;Chocolate&quot;).tag(Flavor.chocolate as Flavor?)
              Text(&quot;Vanilla&quot;).tag(Flavor.vanilla as Flavor?)
              Text(&quot;Strawberry&quot;).tag(Flavor.strawberry as Flavor?)
          }
  
              .padding()
      }
  }
  </code></pre>
  <p>Even though I followed the other answers, as soon as I use a class object it fails.</p>
  <p>What do I need to change to make it working?</p>