In my application I have a textbox that should be filled with a Double
and the number should be saved into a variable but there's an error.
I dragged and dropped the textbox into ViewController.swift
so it should be linked. I created a @IBOutlet
. I called the textbox mmolText
and the variable mmol
.
I tried something like: var mmol = mmolText.text
but it shows an error:
'ViewController.Type' does not have a member named 'mmolText'.
What's the problem? How can I solve it? Besides the type of the content of the textbox is a string but I should convert it into Double
.
Here the code of ViewController.swift is:
import UIKit
class ViewController: UIViewController {
@IBOutlet weak var mmolText: UITextField!
var mmol = mmolText.text
@IBOutlet weak var mmolLabel: UILabel!
@IBOutlet weak var mgLabel: UILabel!
@IBAction func convertBM(sender: AnyObject) {
}
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.
}
}