正如您在标题中看到的那样,我收到一个Sigabrt
的错误消息,该类必须具有有效的NSEntityDescription
。我的答案是我必须添加到项目中以及在何处实现该项目。如果这是一个明显的问题,请不要因为我刚开始使用Swift
和Core Data
编码而对我做出判断。
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
}
}
答案 0 :(得分:0)
尝试评论此行@objc (Trancsaction)
//@objc (Trancsaction)
public class Trancsaction: NSManagedObject {