UIButton inside UISegmentedControl action

UIButton inside UISegmentedControl action

I am continuing my calculation program to improve my skills in Swift code. Right now I have a problem: I want that an UISegmentedControl select the operator of my operations (+, – ecc..) and when one is selected a UIButton func calculate the values based on the decision of the UISegmentedControl.

Here is the code but is not working.

Thanks,
Matteo

import UIKit

class ViewController: UIViewController {


@IBOutlet weak var firstNumber: UITextField!
@IBOutlet weak var secondNumber: UITextField!
@IBOutlet weak var resultButton: UIButton!
@IBOutlet weak var resultNumber: UILabel!
@IBOutlet weak var operatorSelector: UISegmentedControl!

override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view, typically from a nib.


}

override func didReceiveMemoryWarning() {

    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
}


@IBAction func operatorSelectorChanged(_ sender: UISegmentedControl) {
    switch operatorSelector.selectedSegmentIndex {
    case 0:
        @IBAction func resultFunction(_ sender: AnyObject) {
            if let firstNumberConv :Int = Int(firstNumber.text!), let secondNumberConv :Int = Int(secondNumber.text!) {
                let result = firstNumberConv + secondNumberConv
                resultNumber.text = "\(result)"
            } else { resultNumber.text = "Inserire solo valori numerici"}
        }


    case 1:
        @IBAction func resultFunction(_ sender: AnyObject) {
            if let firstNumberConv :Int = Int(firstNumber.text!), let secondNumberConv :Int = Int(secondNumber.text!) {
                let result = firstNumberConv - secondNumberConv
                resultNumber.text = "\(result)"
            } else { resultNumber.text = "Inserire solo valori numerici"}
        }

    default:
        break;

    }

}



}