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
casting dynamic swift nsmanagedobject


source to share


No one has answered this question yet

See similar questions:

120
Could not find specific subclass of NSManagedObject
0
Swift listing NSManagedObject for inactive class fails

or similar:

3486
Why Java + =, - =, * =, / = do not require casting assignment operators?
2964
How to cast int to enum?
2296
Output malloc result?
1510
Regular casting vs. static_cast vs. dynamic_cast
902
# pragma in Swift?
645
Direct casting versus "how" operator?
75
CoreData: warning: unable to load class named
1
Creating a new instance of the NSManagedObject class
1
NSManagedObject is not initialized
0
Subclassed NSManagedObject does not provide a designated Swift initializer



All Articles
Loading...
X
Show
Funny
Dev
Pics