NSNull

Singleton class that represents a null value in collections that don’t accept nil. Returns nil/NULL/0 for all unknown method calls.

Base Class

NSObject

Implemented Protocols

Methods

Singleton Access

Comparison

Dynamic Method Handling

Usage Example

// Get singleton instance
NSNull *null = [NSNull null];

// Use in collections that don't accept nil
NSArray *array = @[@"string", [NSNull null], @"another"];

// All unknown methods return nil/0/NULL
[null someRandomMethod];  // Returns NULL
[null count];            // Returns 0
[null length];           // Returns 0

Important Notes

  1. Singleton Behavior
  2. Implementation Details
  3. Memory Management
  4. Comparison Behavior