compare string with null iOS

Question:

Want to compare string with null iOS sdk.

I want to comapre my string with null values I am getting from my local database.

I tried if (exe_lbl_data.text==nil) and also if (exe_lbl_data.text=@"(null)") but both are showing false.

Answer:

try one or both of the following:

if (nil == str || NSNull.null == (id)str) {
  …
}

In this case, you need to define what Null is. There is a Null type (NS/CF-Null), and there is the concept of the Null pointer. It varies by case (that is, what is returned to you?).

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s