converting string value from text field to integer in Swift 3 &/or Swift 4 : I'm really new to Swift and am having problems with the conversion of a string (entered in a text field) to an integer.

I'm trying to create a small calculation app in XCode 8 (I was following a tutorial on YouTube but it's old).

My app has 3 text fields, a label (that is meant to display the result), and a button to start the calculation.

I'm currently using Swift 3 but if someone could give me the answer for doing it in Swift 3 & Swift 4 I'd be grateful.


Here's the code:

import UIKit

class ViewController: UIViewController {

    @IBOutlet weak var valueA: UITextField!
    
    @IBOutlet weak var valueB: UITextField!
    
    @IBOutlet weak var valueC: UITextField!
    
    @IBOutlet weak var result: UILabel!
    
    
    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 calculateTotal(_ sender: Any) {
        
        var a:Int? = Int(valueA.text)
        var b:Int? = Int(valueB.text)
        var c:Int? = Int(valueA.text)
        var answer = a! * b! * c!
        
        
    }

}

