0

I have an error to which I am not sure on how to fix.

Here is there error

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[SubResultComponent setDate:]: unrecognized selector sent to instance 0x60000046b640'

Here is the SubResultComponent

extension SubResultComponent {

    @nonobjc public class func fetchRequest() -> NSFetchRequest<SubResultComponent> {
        return NSFetchRequest<SubResultComponent>(entityName: "SubResultComponent")
    }

    @NSManaged public var date: String?
    @NSManaged public var price: NSDecimalNumber?

}

This is where I Call set date

func updateUI() {

    guard rateLog != nil else {

        return
    }

    // Update cell UI
    self.dateLabel.text = rateLog?.date
    self.priceLabel.text = numberFormatter.string(from: (rateLog?.price)!)
}

1 Answers1

0

@NSManaged acts similar to the objective c version of dynamic; it is a promise to the compiler that the object will have those properties at runtime. It does not actually make those properties. For this to work these properties need to be setup correctly in the core data model file. Using the editor's "Create NSManagedObject Subclass..." option greatly helps in keeping you code and the model in sync.

Jon Rose
  • 8,373
  • 1
  • 30
  • 36