title: Swift Declared Typed Array from AnyClass object
body: <p>Is there a way in Swift to take an instance of <code>AnyClass</code> and use that to declare an array of that type? </p>
  
  <p>For example, I'm using <a href="https://github.com/gonzalezreal/Overcoat" rel="nofollow">Overcoat</a> and <a href="https://github.com/Mantle/Mantle" rel="nofollow">Mantle</a> to map JSON responses into models that are persisted in CoreData by the frameworks. Before I do a get request, I manually perform a fetch request on the Core Data context and receive back all the persisted models. I then have to use <code>MTLManagedObjectAdapter</code> which turns <code>NSManagedObjects</code> into plain models and back, to map the results from the fetch request into my model objects.</p>
  
  <p>To that end, I made a function that I defined on the base model class:</p>
  
  <pre><code>class func mapResults(results: [NSManagedObject], toModelClass modelClass: AnyClass) -&gt; ([AnyObject], [NSError?]) {
      var transformed: [AnyObject] = []
      var errors: [NSError?] = []
      for result in results {
          var error: NSError? = nil
          var model: AnyObject! = MTLManagedObjectAdapter.modelOfClass(modelClass, fromManagedObject: result, error: &amp;error)
          transformed.append(model)
          errors.append(error)
      }
      return (transformed, errors)
  }
  </code></pre>
  
  <p>I would love to be able to declared <code>transformed</code> as <code>var transformed: [modelClass] = []</code> but for obvious reasons that doesn't work. Is there any way to convert that <code>AnyClass</code> object into a type or is it just not possible right now in Swift?</p>