Throw NSManagedObject into class & # 8594; Dynamic transfer shift failed

Hope you can help!

I have a class called Exercise:

import Foundation
import CoreData

class Exercise: NSManagedObject
{
@NSManaged var name: String
}

      

and created an Entity called Exercise with a "name" attribute of type String.

Now I want to access it from ViewController:

var context = (UIApplication.sharedApplication().delegate as AppDelegate).managedObjectContext!
var exercise: NSManagedObject = NSEntityDescription.insertNewObjectForEntityForName("Exercise", inManagedObjectContext: context) as Exercise

      

But if I try now and run it then the codes will stop in Thread1 in swift_dynamicCastClassUnconditional with "Dynamic dynamic failure too much "

I tried this in another project and it worked, I can't find the error!

Thanks in advance!

+3


source to share





All Articles