title: Index out of range SwiftUI
body: <p>I have declared a struct, which should have an id and a litereal</p>
  
  <pre><code>struct Lit: Identifiable, Codable {
      var id      : Int
      var literal : String
  }
  </code></pre>
  
  <p>Here is my code where I decode a JSON file into a list:
  The JSON file contains 3 items </p>
  
  <pre><code>[{"id":0,"literal":"arda"},{"id":0,"literal":"mecho"},{"id":0,"literal":"dossi"}]
  </code></pre>
  
  <pre><code>class Literal: ObservableObject {
  
    @Published var lit = [Lit]()
  
    init() {
      loadLiteral()
    }
    func loadLiteral(){
  
      guard let url = URL(string: "http://biobeehive.com/Dossi.json") else {return}
  
      URLSession.shared.dataTask(with: url ) { (data,_,_) in
        guard let data = data else {return}
  
        let pokemon200 = try! JSONDecoder().decode([Lit].self, from: data)
  
        DispatchQueue.main.async  {
          self.lit  = pokemon200
          print("\(self.lit[0].literal)")
        }
      }.resume()
  
    }
  }
  </code></pre>
  
  <p>Bellow, I want to print the literal at index 0, it should print "arda", but instead of that I get an error.( Fatal error: Index out of range: file ), even though I see that all the 3 items exist and have been passed.</p>
  
  <pre><code>struct ContentView: View {
  
    @ObservedObject var literal = Literal()
  
    var body: some View {
  
      VStack {
  
        Text("\(literal.lit.count)")   // Output is 3
        Text("\(literal.lit[0].literal)") //Crashing here
  
      }
  }
  </code></pre>
  
  <p>Would you please tell me how to fix that?</p>