網頁

2012年5月20日 星期日

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.

沒有留言:

張貼留言