tags:

views:

90

answers:

1

So there 's NULL, which is used for pointers in general, and nil, which is used for object pointers.

Now I see there's also Nil, which is used by lower-level Obj-C runtime functions like class_getProperty.

Is this somehow different from nil philosophically? (yes, I know they're all actually 0)

Why was it even introduced? Or, if Nil was first (which is likely), why was nil introduced?

+6  A: 

Googling "Nil vs nil" found this post http://numbergrinder.com/node/49, which states:

All three of these values represent null, or zero pointer, values. The difference is that while NULL represents zero for any pointer, nil is specific to objects (e.g., id) and Nil is specific to class pointers. It should be considered a best practice of sorts to use the right null object in the right circumstance for documentation purposes, even though there is nothing stopping someone from mixing and matching as they go along.

Damien_The_Unbeliever
Yup, I've seen that page, but I didn't believe it was just for Class pointers. Now, after reading <objc/objc.h>, it seems this really is the case :)
Jaka Jančar