November 2013
Beginner
325 pages
9h 47m
English
Nearly all object-oriented languages have the idea of nil, the pointer to no object. In Objective-C, we use nil instead of NULL, which was discussed in Chapter 9. They really are the same thing: the zero pointer. By convention, though, we use nil when referring to the value of an empty pointer declared as pointing to an Objective-C object type, and NULL when referring to any other pointer, such as to a struct.
In most object-oriented languages, sending a message to nil is not allowed. As a result, you have to check for non-nil-ness before accessing an object. So you see this sort of thing a lot:
if (fido != nil) {
[fido goGetTheNewspaper];
}
When Objective-C was designed, it was decided that sending a ...
Read now
Unlock full access