title: Swift CoreData Failed to call designated initialiser on NSMangedObjectClass
body: <p>I have 2 classes. My <code>MainScreenViewController</code> and my <code>DataFetch</code>. In the DataFetch class I have a function <a href="https://gist.github.com/foffer/04f92649d2d491eb75f0" rel="nofollow noreferrer"><code>func loadDesserts(){...}</code></a> where I setup my RestKit and CoreData entity/objectMappings and all the rest.</p>
  <p>That function is called from <code>MainScreenViewController</code>. But when the class is assigned to a constant: <code>let dataFetch = DataFetch()</code> it throws the error:</p>
  <pre><code>CoreData: error: Failed to call designated initializer on NSManagedObject class '_TtC9Kogekunst9DataFetch'
  </code></pre>
  <p>I've come to the conclusion (although not a 100% certain) that RestKit is not to blame for this problem. I think I'm not initialising the NSManagedObject correctly. I've tried implementing the</p>
  <pre><code>init(entity entity: NSEntityDescription!,
  insertIntoManagedObjectContext context: NSManagedObjectContext!)
  </code></pre>
  <p>But I haven't managed to get it working, as it gives me the same error. The way I tried to implement it was as follows:</p>
  <pre><code>    var context: NSManagedObjectContext = RKObjectManager.sharedManager().managedObjectStore.mainQueueManagedObjectContext
      var entity = NSEntityDescription.entityForName(&quot;Dessert&quot;, inManagedObjectContext: context)
      let dataFetch = DataFetch(entity: entity, insertIntoManagedObjectContext: context)
      dataFetch.loadDesserts()
  </code></pre>
  <p>But that throws an 'Fatal - Can't unwrap Optional.none'. So stuck again.</p>
  <p>Could someone point me in the right direction as to what to do?</p>
  <p>Chris</p>