title: XPC connection interrupted while trying to get data from web api in swift
body: <p>my json return this</p>
  <pre><code>{
  &quot;status&quot;:&quot;false&quot;,
  &quot;subjects&quot;:
  [
  {
  &quot;id&quot;:1,
  &quot;subjectName&quot;:&quot;English&quot;
  },
  {
  &quot;id&quot;:3,
  &quot;subjectName&quot;:&quot;Mathemetics&quot;
  }
  ]
  }
  </code></pre>
  <p>here is the swift code</p>
  <pre><code>struct SyllabusSubjects: Codable {
      let subjects: [Subject]
  }
  
  struct Subject: Codable {
      let subjectName: String?
  }
  </code></pre>
  <p>i am trying to show the list of subjects on a screen when it loads.</p>
  <pre><code>func getSubject(pid: String)
      {               
          var url : URL = URL(string: &quot;http://example.com/webapi/Users.php?action=GetParentSubject&amp;pId=&quot;+pid)!
          
          let loadsubjectdata = URLSession.shared.dataTask(with: url, completionHandler: dataLoaded) 
          loadsubjectdata.resume()
      }
      
       func dataLoaded(data:Data?, response:URLResponse?, error:Error?){
         
          if let detailData = data{
                      print(&quot;detaildata&quot;, detailData)
                      let decoder = JSONDecoder()
                      do {
                          let jsondata = try decoder.decode(SyllabusSubjects.self, from: detailData)
                          
                          print(jsondata.subjects)
                          
                      }catch let error{
                          print(error)
                      }
                  }else{
                      print(error!)
                  }
  
      }
  </code></pre>
  <p>when i try to print data it shows = 42 bytes
  along with this error message</p>
  <p>keyNotFound(CodingKeys(stringValue: &quot;subjects&quot;, intValue: nil), Swift.DecodingError.Context(codingPath: [], debugDescription: &quot;No value associated with key CodingKeys(stringValue: &quot;subjects&quot;, intValue: nil) (&quot;subjects&quot;).&quot;, underlyingError: nil))</p>