how to Check NSString is null or not [duplicate] how to Check NSString is null or not [duplicate] xcode xcode

how to Check NSString is null or not [duplicate]


Like that:

[myString isEqual: [NSNull null]];


There are three possible interpretations of "null" NSString:

  1. someStringPtr == nil
  2. (id)someStringPtr == [NSNull null]
  3. someStringPtr.length == 0

If you may have the possibility of all 3, the 3rd check subsumes the first, but I don't know of a simple check for all three.

In general, JSON will return [NSNull null] for a null JSON value, but some kits may return @"" (length == 0) instead. nil will never be used in iOS since it can't be placed in arrays/dictionaries.


Try if(myString == [NSNull null]). That should evaluate it properly.