3 回答

TA貢獻(xiàn)1936條經(jīng)驗 獲得超7個贊
您可以nil
在任何可以使用的地方使用null
。主要區(qū)別在于您可以將郵件發(fā)送到nil
,因此可以在null
無法正常工作的某些地方使用它。
通常,只需使用即可nil
。

TA貢獻(xiàn)1735條經(jīng)驗 獲得超5個贊
我發(fā)現(xiàn)以下內(nèi)容:
objc.h
#define Nil __DARWIN_NULL /* id of Nil class */
#define nil __DARWIN_NULL /* id of Nil instance */
_types.h
#define __DARWIN_NULL ((void *)0)
stddef.h
#undef NULL
#ifdef __cplusplus
#undef __null // VC++ hack.
#define NULL __null
#else
#define NULL ((void*)0)
#endif
MacTypes.h
#ifndef NULL
#define NULL __DARWIN_NULL
#endif /* ! NULL */
#ifndef nil
#define nil NULL
#endif /* ! nil */
看起來,沒有什么區(qū)別,只是概念上的區(qū)別。
- 3 回答
- 0 關(guān)注
- 590 瀏覽
添加回答
舉報