我刚刚继承了这个应用程序,并且试图在表单中添加一些字段。
我收到此错误-它似乎正在MedicalDevice上调用setPrice方法。
据我所知,我已经为期望的课程加价了……
@objc(MedicalDevice)
public class MedicalDevice: NSManagedObject {
static let entityName = "MedicalDevice"
@nonobjc public class func fetchRequest() -> NSFetchRequest<MedicalDevice> {
return NSFetchRequest<MedicalDevice>(entityName: MedicalDevice.entityName)
}
convenience init(context moc: NSManagedObjectContext) {
self.init(entity: NSEntityDescription.entity(forEntityName: MedicalDevice.entityName, in: moc)!, insertInto: moc)
}
@NSManaged public var createdAt: Date?
@NSManaged public var deviceID: String?
@NSManaged public var expirationDate: Date?
@NSManaged public var lotNumber: String?
@NSManaged public var modelNumber: String?
@NSManaged public var catalogNumber: String?
@NSManaged public var deviceDescription: String?
@NSManaged public var brandName: String?
@NSManaged public var companyName: String?
@NSManaged public var quantity: String?
@NSManaged public var price: String?
@NSManaged public var location: String?
@NSManaged public var facilityID: String?
}
addDevice就这样工作-这是引发异常的地方:
func addDevice(for deviceID: String, lotNumber: String, expirationDate: Date, modelNumber: String, catalogNumber: String, description: String, quantity: String, brandName: String, companyName: String, price: String, location: String, facilityID: String) {
let medicalDevice = MedicalDevice(context: self.persistentContainer.viewContext)
medicalDevice.createdAt = Date()
medicalDevice.deviceID = deviceID
medicalDevice.lotNumber = lotNumber
medicalDevice.expirationDate = expirationDate
medicalDevice.modelNumber = modelNumber
medicalDevice.catalogNumber = catalogNumber
medicalDevice.deviceDescription = description
medicalDevice.quantity = quantity
medicalDevice.brandName = brandName
medicalDevice.companyName = companyName
medicalDevice.price = price
medicalDevice.location = location
medicalDevice.facilityID = facilityID
self.saveContext()
}
现在,我没有看到任何setPrice方法(这很有意义,我只是在各个字段中添加了它),但是我也没有看到setX,X是肯定要保存的其他任何字段
可能是什么原因造成的?显然,setPrice是在某个地方被调用的(以某种方式生成?),我猜它不存在。