I would like to check in my app, if there is already a -
character in the textField
.
How can I do this?
I would like to check in my app, if there is already a -
character in the textField
.
How can I do this?
You can use contains()
method
let myString = "test"
if myString.contains("e"){
let index = myString.index(of: "e")
myString.remove(at: index!)
}
p.s you can get myString
from textField.text
You can simply:
var yourTextFieldString: String = textField.text
yourTextFieldString.contains("-")
It returns a Bool.