Search code examples
iosxcodeipadunrecognized-selector

Unrecognized selector on row "addTarget...", how to solve?


I have the following code:

self.firstStepper.addTarget(self, action: #selector(CheckupStepTableViewCell.stepperValueChanged(_:)), forControlEvents: .ValueChanged)

that crash only on my iPad users (sometime) in iOS 9 and 10. Error is:

error image

But I really don't know why. Any idea?


Solution

  • It looks like self.firstStepper is getting set to a UIView that is not a UIControl. addTarget is a method on UIControl.