1. nil: Generally, it is assigned to an empty object;
2. NULL: It is generally assigned to NULL values other than nil. Such as SEL;
Give me a chestnut (so heavy ~) :
[NSApp beginSheet: sheet
ModalForWindow: mainWindow
ModalDelegate: nil // pointing to an object
DidEndSelector: NULL // pointing to a non object/class
ContextInfo: NULL]; // pointing to a non object/class
3. NSNULL: NSNull has only one method: + (NSNull *) null;
[NSNull null] is used to add a non-nil (indicating the end of the list) null value to NSArray and NSDictionary. [NSNull null] is an object, which is used when nil cannot be used.
4. When a message is sent to nil, NO is returned and NO exception is thrown. The program continues to run;
An exception is thrown when a message is sent to an NSNull object.
Because nil in NSArray and NSDictionary has a special meaning (indicating the end of the list), the nil value cannot be placed in the set. To store a value indicating "nothing", you can use the NSNull class. There is only one NSNull method:
+ (NSNull *) null;
Nil is an object pointer with NULL values, Nil is a class pointer with NULL values, and NULL is a basic data type with NULL values. These can be understood as the difference between nil, Nil, and NULL.