Chapter 7. Making Friends with nil
Dealing with nil (null) references is an inevitable part of programming. This chapter will explain how nil and NULL pointers are handled in Objective-C, and some of the surprising consequences. Learning to use nil object pointers to your advantage can substantially simplify—rather than complicate—your design.
nil (null) and NULL references are sometimes treated more harshly in Objective-C than they are in Java, but are at other times permitted—embraced, even. Java is very consistent in its treatment of null; use of a null reference is universally considered a programming error and throws a java.lang.NullPointerException object at runtime. Runtime exceptions typically terminate the Java application, but can be ...
Get Learn Objective-C for Java Developers now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.