views:

225

answers:

1

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.

+5  A: 
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.

John Calsbeek