iPhone SDK Articles
NULL or nil?
In Cocoa both of them are typedef to zero. nil is an object pointer, whereas NULL is a c pointer. If you want to set char * to 0 then you would set it to NULL and if you want to set a view controller to 0 then you would set it to nil. Cocoa also gives us another typedef called “Nil” (notice the case) which is class pointer. Now you know when to use the correct null pointer.
One Response to NULL or nil?
Tags





Inside MacTypes.h, there is a definition about `nil`.
#ifndef nil
#define nil NULL
#endif /* ! nil */