Special nil handling means you can do the following:
SomeClass * someObject; someObject = nil; [someObject doSomething];
And you can be sure that nothing will happen.
Now why is this important?
In Objective-C, sending a message to an object means telling the object to do something, or requesting that object for some information. Some examples:
[someObject updateRecords];
Line 1 sends someObject message called updateRecords , and line 2 sends a message with the name size to the same object, which is expected to return a value. These messages come down to method calls, and the actual code that ends with the run is determined by the Objective-C runtime system, since Objective-C is a dynamically typed language.
To determine which method to call, the runtime reads information from the address of the object in question ( someObject , in the examples above) to determine which class is an instance. Using this information, he can look for the appropriate method to call, and when everything that has been found out, it runs the code in the method.
If the runtime system did not consider nil as a special case, it is likely to crash if you try to execute the code shown at the top. nil defined as zero, so the runtime will begin to read information from the address stored in the zero location in memory, which is almost guaranteed to violate access rights.
source share