Null object: Difference between revisions

Content added Content deleted
(Fixing an error in Objective-C semantics)
Line 284: Line 284:
NSLog("object is nil");
NSLog("object is nil");
}</lang>
}</lang>
An interesting thing is that in Objective-C, it is possible to send a message to <code>nil</code>, and the program will not crash (nothing will be executed; an exception is raised, but it does not interrupt the program).
An interesting thing is that in Objective-C, it is possible to send a message to <code>nil</code>, and the program will not crash or raise an exception (nothing will be executed and <code>nil</code> will be returned in place of the usual return value).
<lang objc>[nil fooBar];</lang>
<lang objc>[nil fooBar];</lang>