title: Core Data: Could not cast value of type 'MyType_MyType_2' to MyType
body: <p>I have an Objective-C model class MyType. This class is used in Swift code:</p>
  
  <pre class="lang-c prettyprint-override"><code>NSEntityDescription.insertNewObjectForEntityForName("MyType", inManagedObjectContext: context) as! MyType
  </code></pre>
  
  <p>The <code>as!</code> cast results in the error message </p>
  
  <pre><code>Core Data: Could not cast value of type 'MyType_MyType_2' (0x7be99a30) to MyType (0xf33db74).
  </code></pre>
  
  <p>If I cast it as <code>NSManagedObject</code> it works. When I print the result, I can nevertheless see, that it is an actual instance of MyType:</p>
  
  <pre><code>&lt;MyType: 0x7ae06d50&gt; (entity: MyType; id: 0x7aeba6d0 &lt;x-coredata:///MyType/t957F2860-85F8-46E0-B6D6-4D1DF6C4EC613&gt; ; data: { 
      ...the fields...
  })
  </code></pre>
  
  <p>What is happening here? And where does the name <code>MyType_MyType_2</code> come from?</p>