title: iOS: Cast result of coredata fetch to array and passing to another class
body: <p>in my class I have a method to extract data from coredata. But I have a problem: I need to convert the result to an array, because then I'll have to use that array in an other class.</p>
  
  <p>The method is:</p>
  
  <pre><code>    func loadQuestion() -&gt; NSArray{
          let fetchRequest: NSFetchRequest&lt;Questions&gt; = Questions.fetchRequest()
  
          do {
              let array = try self.context.fetch(fetchRequest) as NSArray
              guard array.count &gt; 0 else { print("[EHY!] Non ci sono elementi da leggere "); return array }
  
              return array
          } catch let errore {
              print("error FetchRequest")
          }
  
          return list 
      }
  </code></pre>
  
  <p>I can't figure out how to convert the variable array?</p>
  
  <p>The result (wrong)</p>
  
  <p><a href="https://i.stack.imgur.com/PbOk2.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/PbOk2.jpg" alt="enter image description here"></a></p>
  
  <blockquote>
    <p>Edit: I write this because I want to convert the result of fetch into
    an array, so you can switch to another class</p>
  </blockquote>