title: Swift CoreData: error: Failed to call designated initializer on NSManagedObject class 'NSManagedObject'
body: <p>I'm using core data to save a category in vc1 and want to add list properties to a list in vc2. My data model is one category to many list properties.</p>
  
  <p>I'm adding the category like this in vc1:</p>
  
  <pre><code>func createNewCategory() {
      var category: NSManagedObject! = NSEntityDescription.insertNewObjectForEntityForName("Category", inManagedObjectContext: self.context) as NSManagedObject
      category.setValue(self.categoryTextField.text, forKey: "name")
  
      var error: NSError? = nil
      self.context.save(&amp;error)
  }
  </code></pre>
  
  <p>Setting up the data in vc2:</p>
  
  <pre><code>func setupCoreData() {
      var appDelegate: AppDelegate = (UIApplication.sharedApplication()).delegate as AppDelegate
      self.context = appDelegate.managedObjectContext!
  
      var request: NSFetchRequest = NSFetchRequest(entityName: "Category")
      if (self.context.executeFetchRequest(request, error: nil)) {
          var error: NSError? = nil
          self.listData = self.context.executeFetchRequest(request, error: &amp;error)
          self.managedObject = self.listData.objectAtIndex(0) as NSManagedObject
      }
  }
  </code></pre>
  
  <p>It crashes on the last row: <code>self.managedObject = ...</code> saying:</p>
  
  <pre><code>CoreData: error: Failed to call designated initializer on NSManagedObject class 'NSManagedObject' 
  </code></pre>
  
  <p>The managed object is in the array if I put a break point and print the array. What's wrong? </p>