Q:

How to convert a text input from a string into a float

I am creating a calculator/unit conversion app, and simply want text input to only accept floats and integers. I have tried making the text input keyboard a numberpad, but the program is still treating it as a "String?". 
Edit: My end goal is to have a text input that accepts floats, and can allow my program to treat that as such. Currently, when a number is entered, the code still treats it as a string. I want it to be converted to a float.
I read that using (...as NSString).floatValue would work, but doesn't seem to be working for me. Here is my code
import UIKit

class ViewController: UIViewController{
    @IBOutlet weak var numberOutput: UILabel!
    @IBOutlet weak var numberInput: UITextField!

    //

    @IBAction func onTouchDown(_ sender: UITextField) {
        var number = (numberInput.text as NSString).floatValue
        print(number*2)
    } 
}

A:

Found this source: https://www.youtube.com/watch?v=-ilRn7VrL9M
This guy did it the simplest way:
@IBOutlet weak var numberINput: UITextField!
@IBAction func calculateButton(_ sender: Any) {
    let numberString = numberINput.text
    let number = NSString(string: numberString!).floatValue
    let finalValue = number*3
    resultsTxt.text = "\(finalValue)"

So I did end up having to use NSString, just not the original way I had learned/tried. Thanks to all of those that helped!

