user4887505 user4887505 - 4 months ago 31
iOS Question

Crash in CoreData

Getting error:

Unable to load class named 'MyClass' for entity 'Myentity'. Class not found, using default NSManagedObject instead.

my code is:

import CoreData

class MyClass: NSManagedObject {

@NSManaged var title: String
@NSManaged var descriptions: String
@NSManaged var status: String
@NSManaged var issuePagePath: String
}


Crash point:

let newItem = NSEntityDescription.insertNewObjectForEntityForName("Myentity", inManagedObjectContext: managedObjectContext) as! MyClass

Answer

Add this line:

@objc(MyClass)

before:

class MyClass: NSManagedObject 
Comments