Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to Check NSString is null or not [duplicate]

Tags:

I want to check weather a NSString is null or not. Im assigning from an JSON array. After assigning that string value is <null>. Now I want to check this string is null or not. So I put like this

if (myStringAuthID==nil) but this if statement always false. How I can check a string for null. Please help me

Thanks

like image 951
user2889249 Avatar asked Oct 23 '13 16:10

user2889249


People also ask

How do I know if my NSString is empty?

You can check if [string length] == 0 . This will check if it's a valid but empty string (@"") as well as if it's nil, since calling length on nil will also return 0. There are some very rare NSStrings where this will result in a false negative (saying the string isn't empty, when, for practical purposes, it is).

What does NSString mean?

A static, plain-text Unicode string object which you use when you need reference semantics or other Foundation-specific behavior.


1 Answers

Like that:

[myString isEqual: [NSNull null]]; 
like image 187
Mirko Catalano Avatar answered Oct 06 '22 02:10

Mirko Catalano