我找不到我的代码出了什么问题。我正在尝试将MagicalRecord与Swift结合使用。当我在做简单的createEntity时,它的值为零:
let a = Subject.MR_createEntity() <--- This line is working perfectly
let b = Points.MR_createEntity() <--- This line returns nil
let c = Class.MR_createEntity() <--- This line returns nil
这是我的类实现:
学科:
@objc(Subject)
class Subject: NSManagedObject {
@NSManaged var name: String?
@NSManaged var classes: NSSet?
}
类:
@objc(Class)
class Class: NSManagedObject {
@NSManaged var name: String?
@NSManaged var teacherName: String?
@NSManaged var subject: Subject?
@NSManaged var points: NSSet?
}
要点:
@objc(Points)
class Points: NSManagedObject {
@NSManaged var date: NSDate?
@NSManaged var points: NSNumber?
@NSManaged var maxPoints: NSNumber?
@NSManaged var classType: Class?
}
然后从.xcdatamodel屏幕:
最佳答案
初始化MagicalRecord时,您可以启用核心数据日志,然后您将知道创建实体失败时会发生什么。
MagicalRecord.setLoggingLevel(MagicalRecordLoggingLevel.Warn)
关于ios - 魔术记录-MR_createEntity返回nil,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/37058708/