is there a method to verify if a NSString haven't characters? example of string without characters can be:
@"" or @" " or @"\n " or @"\n\n ", I want cosider these strings as empty strings and print a nslog that say me that these are emty, what kind of control I should use?
The isEmpty() method checks whether a string is empty or not. This method returns true if the string is empty (length() is 0), and false if not.
Use the length property to check if a string is empty, e.g. if (str. length === 0) {} . If the string's length is equal to 0 , then it's empty, otherwise it isn't empty.
In C#, IsNullOrEmpty() is a string method. It is used to check whether the specified string is null or an Empty string.
isEmpty(< string >)Checks if the <string> value is an empty string containing no characters or whitespace. Returns true if the string is null or empty.
You can use this test:
if ([[myString stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] length] == 0) {
// The string is empty
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With