iOS to determine whether the content in the TextView is empty
in the development of iOS, it is often necessary to determine whether the data in the TextView box is empty or whether it is a space, following the syntax of Swift as an
example to explain a method of judgment
//method one
if self.titleValue.text? .StringByTrimmingCharactersInSet (NScharacterSet.WhiteSpaceCharac-
terSet ()). StringLength () == 0 {
print ("What is used here is to remove all space characters in the textView, and then determine whether the length of the characters after removing the space characters is 0")
}
//Method Two
if self.titleValue.text? .StringByTrimmingCharactersInSet (NScharacterSet.WhiteSpaceCharac-
terSet ()) == "" {
print ("Use here to directly determine whether the characters in the textView string after removing the space characters are null characters")
}
Ways to get rid of String hollow characters
var string = "Hello Hello world"
string = String.stringbyreplacingoccurrencesofstring ("", Withstring: "")//This When the string
changes to "Hellohelloworldworld"
Swift's for Loop
For I in string.characters{
if I >= "0" && I <= "9" {
//delete a numeric character in a string let
index = String.ran Geofstring ("\ (i)")
String.removerange (index!)
}
}