What is the best was to determine if an NSString is empty? Right now I am using the following:
if (string == nil || [string isEqualToString:@""]) {
// do something }
Thanks for any advice.
A static, plain-text Unicode string object that bridges to String ; use NSString when you need reference semantics or other Foundation-specific behavior.
if ([string length] == 0) {
// do something
}
If the string is nil
, then the message to nil
will return zero, and all will still be well.
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