I am trying to incorporate a UIStepper
into a UITextField
, while incrementing the value of the stepper, the UITextField
updates with it to that value. I keep getting the error:
"Terminating app due to uncaught exception ''NSInvalidArgumentException', reason: '-[Calculator.SplitViewController stepperValueChanged:]: unrecognized selector sent to instance 0x7fd730c0af30"`
Whenever I run my app and tap the "+" button on the stepper.
Any solutions? I checked my selector function and I think it looks right.
override func viewDidLoad() {
super.viewDidLoad()
partyOfStepper.autorepeat = true
partyOfStepper.minimumValue = 1
partyOfStepper.maximumValue = 99
partyOfTextField.text = "\(Int(partyOfStepper.value))"
partyOfStepper.addTarget(self, action: #selector(stepperValueChanged(stepper:)), for: .valueChanged)
}
@IBAction func calculateButtonTapped(_ sender: Any) {
}
func stepperValueChanged(stepper: UIStepper) {
let stepperMapping: [UIStepper: UITextField] = [partyOfStepper: partyOfTextField]
stepperMapping[stepper]!.text = "\(Int(stepper.value))"
}