Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 505 Vote(s) - 3.5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
When should I use nil and NULL in Objective-C?

#11
There is a difference in some contexts.

Literally, Null is a character: ASCII 0.

Nil is equivalent to blank, no value.

Depending on the programming context, this can be a big difference.
Reply

#12
Beware that `if([NSNull null])` returns `true`.
Reply

#13
You can use `nil` about anywhere you can use `null`. The main difference is that you can send messages to `nil`, so you can use it in some places where `null` cant work.

In general, just use `nil`.
Reply

#14
nil means absence of value while NULL represent No Object,

NSArray *array = @[@"Hello World !", @101,[NSNULL null] ];

Here [NSNULL null] is an object which means no object, at the same time you cannot add nil to indicate absence of object.

you can use both nil and [NSNUll null] for checking too.

Reply

#15
This will help you to understand the difference between nil, NIL and null.

The below link may help you in some way:

[To see links please register here]


> nil -> literal null value for Objective-C objects.
>
> Nil -> literal null value for Objective-C classes.
>
> NULL -> literal null value for C pointers.
>
> NSNULL -> singleton object used to represent null.
Reply

#16
Basically:
nil: null pointer on an object and
null: is for other type pointer
Reply

#17
**nil** is an object pointer to nothing.
Although semantically distinct from **NULL**, they are technically **equivalent** to one another.

On the framework level, Foundation defines **NSNull**, which defines a class method, +null, which returns the singleton NSNull object. **NSNull** is different from **nil** or **NULL**, in that it is an **actual** **object**, rather than a zero value.

Additionally, in Foundation/NSObjCRuntime.h, **Nil** is defined as a **class** **pointer** to nothing.

[Refer this for further info - nil / Nil / NULL / NSNull][1]


[1]:

[To see links please register here]

"nil / Nil / NULL / NSNull"
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through