How can you use the \"ctype.h\" library in Swift to be able to use isAlpha
or isSpace
on characters? Or is there a better, Swift, way of doing it?
This answer works with text fields. I was going crazy trying to search for whitespace on a UItextfield without searching the string content of it. This works for UItextfields:
Swift 4:
if (textField.text?.contains(" "))!{
print("Has space")
}else{
print("Does not have space")
}
This is for a regular string, also in swift 4
if string.contains(" "){
print("Has space")
}else{
print("Does not have space")
}