Null is defined in C, but C does not include nil, nil, and nsnull. These three are part of objective-C (hereinafter referred to as OC.
Int * A = NULL;
A null pointer to anything else, is for C-style memory pointers.
It is a pointer variable of the C type. It is a null pointer and does not point to any place. Its value in memory is set to 0. For example, if int * pointer = NULL, the pointer variable pointer has a value of 0 in the memory and does not point to any place.
Essence: NULL pointer
Class * class = nil;
Nil: a null pointer to an objective-C class. (NULL pointer of the OC class .)
Essence: NULL pointer. They are null at all.
[Nsarray arraywithobjects: @ "Steve Jobs", [nsnull null], @ "Tim Cook", nil];
Official explanation:NsnullClass defines a singleton object used to represent null values in collection objects (which don't allowNilValues ).
Nsnull inherits from nsobject. There is only one method [nsnull null]. When this method is called, a space is opened in the memory and the first address pointer of the space is returned. It has only one purpose, that is, it represents an empty object in the Set object, and plays a role in the trap;
Nature: Empty objects
(1) null, nil, and nil are essentially empty pointers. The following test code:
If (null = nil & null = nil)
Nslog (@ "null = nil & null = nil ");
Else
Nslog (@ "null! = Nil | null! = Nil ");
Console print result: "null = nil & null = nil ".
(2) What is the difference between a null pointer and a null object.
The latter points to the nsobject object opened in the heap memory, and the former does not point to any.
(3) Use null, nil, and nil encoding correctly.
Nsobject * OBJ = NULL;
Int * A = nil;
Class * class = nil;
If your code misuse null, nil, and nil like this, you are a programmer with no tricks!
Author's statement: if any error occurs, please point it out. Thank you!