I'm not a Ruby programmer, so I might miss something subtle, but it seems like it does so that you can safely intercept method calls, even when one method call can return zero. This is built into Objective-C because calling nil methods (actually correctly named for sending messages) is safe and perfectly acceptable. Messages in nil always return zero and are mostly no-op. In Objective-C, this is normal:
id foo = [someObject objectByDoingSomething];
id bar = [foo objectByDoingSomethingElse];
NSLog(@"foo: %@ bar: %@", foo, bar);
Therefore, this is also good, even if objectByDoingSomething can return nil:
id foo = [[someObject objectByDoingSomething] objectByDoingSomethingElse];
From Objective-C Programming language : "In Objective-C, really, you need to send a message to nil-it just has no effect at run time." This document provides more detailed information on the exact behavior of nil invocation methods in Objective-C.
source
share