I have an input UITextField
and want to change his value.
I defined this UITextField
like this:
@IBOutlet weak var valueInput: UITextField!
Than in viewDidLoad()
I make delegate
- self
:
valueInput?.delegate = self
and then in viewDidLoad
I try to assign value to input like this:
if let priceIn = self.valueIn Input {
valueIn.text! = strPr // (this is var and it has String format I've checked it, and I also try to make print(strPr) and I get a value)
}
Unfortunately this string is not working:
valueIn.text! = strPr
But if I write something like this
valueIn.text! = "11"
This one will work.
I've tried to to something like this also, but it's not working also:
valueIn.text! = "\(strPr)"
Anyone have any ideas?
Thanks for any answer, hope somebody had the same problem and know how to resolve it.
These lines are wrong:
valueIn.text!
should only appear on the right side, in case you are sure valueIn references a valid object (not nil) and text is declared asvar text: String?
Not sure exactly how your variables are declared, but try something like this:
Or, if strPtr is an Optional, try this: