Possible Duplicate:
NULL vs nil in Objective-C
Objective-C: What's the difference between NULL, nil and @“”?
all I have a simple problem that my objective variable has NULL value in it. and it simply enter in the if condition. I have to check that if variable objective length is greater then zero and no null value then enter in condition.
and When I use NULL or nil in comparison?
THANKS
They are the same. However, it is conventional to use nil
to compare against an objc object, and when assigning to an objc object.
Assuming we're talking about Objective-C:
nil
(all lower-case) is a null pointer to an Objective-C object.
Nil
(capitalized) is a null pointer to an Objective-C class.
NULL
(all caps) is a null pointer to anything else.
In this case it seems that you have a string with a value of "(null)". This can happen when you attempt to append or format content into the string that was null itself. It's a valid string that is not NULL or nil and is 8 characters long. So it enters your loop.
In objective-c, NULL and nil are the same thing (the number 0). But the style guide will tell you to use NULL for pointers and nil for classes derived from NSObject.
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