As you can see in the title I'm getting a Sigabrt
with error that class must have a valid NSEntityDescription
. My answer is what I have to add to my project and where I have to implement this. If this is a obvious question don't judge me because I have just started with Swift
& Core Data
coding.
import UIKit
import CoreData
@objc (Trancsaction)
public class Trancsaction: NSManagedObject {
var date: Date?{
get{
return rawDate as Date?
}
set {
rawDate = newValue as NSDate?
}
}
convenience init?(money: Double, date: Date?, reason: String?) {
let appDelegate = UIApplication.shared.delegate as? AppDelegate
guard let context = appDelegate?.persistentContainer.viewContext else {
return nil
}
self.init(entity: Trancsaction.entity(), insertInto: context)
self.reason = reason
self.money = money
self.date = date
}
}
Try commenting this line @objc (Trancsaction)
//@objc (Trancsaction)
public class Trancsaction: NSManagedObject {