title: SwiftUI View not updating based on @ObservedObject
body: <p>In the following code, an observed object is updated but the View that observes it is not. Any idea why?</p>
  
  <p>The code presents on the screen 10 numbers (0..&lt;10) and a button. Whenever the button is pressed, it randomly picks one of the 10 numbers and flips its visibility (visible→hidden or vice versa).</p>
  
  <p>The print statement shows that the button is updating the numbers, but the View does not update accordingly. I know that updating a value in an array does not change the array value itself, so I use a manual <code>objectWillChange.send()</code> call. I would have thought that should trigger the update, but the screen never changes.</p>
  
  <p>Any idea? I'd be interested in a solution using <code>NumberLine</code> as a class, or as a struct, or using no <code>NumberLine</code> type at all and instead rather just using an array variable within the <code>ContentView</code> struct.</p>
  
  <p><a href="https://i.stack.imgur.com/oiGUd.png" rel="noreferrer"><img src="https://i.stack.imgur.com/oiGUd.png" alt="Screenshot"></a></p>
  
  <p><strong>Here's the code:</strong></p>
  
  <pre><code>import SwiftUI
  
  struct ContentView: View {
  
      @ObservedObject var numberLine = NumberLine()
  
      var body: some View {
          VStack {
              HStack {
                  ForEach(0 ..&lt; numberLine.visible.count) { number in
                      if self.numberLine.visible[number] {
                          Text(String(number)).font(.title).padding(5)
                      }
                  }
              }.padding()
  
              Button(action: {
                  let index = Int.random(in: 0 ..&lt; self.numberLine.visible.count)
                  self.numberLine.objectWillChange.send()
                  self.numberLine.visible[index].toggle()
                  print("\(index) now \(self.numberLine.visible[index] ? "shown" : "hidden")")
              }) {
                  Text("Change")
              }.padding()
          }
      }
  }
  
  class NumberLine: ObservableObject {
      var visible: [Bool] = Array(repeatElement(true, count: 10))
  }
  </code></pre>