Symbol | Value | Meaning |
---|---|---|
NULL | (void *)0 | literal null value for C pointers |
nil | (id)0 | literal null value for Objective-C objects |
Nil | (Class)0 | literal null value for Objective-C classes |
NSNull | [NSNull null] | singleton object used to represent null |
C represents nothing as 0 for primitive values, and NULL for pointers (which is equivalent to 0 in a pointer context).C里面表示什么都没有就像0作为原始值,NULL指向内容为0的指针。
Objective-C builds on C's representation of nothing by adding nil. nil is an object pointer to nothing. Although semantically distinct from NULL, they are equivalent to one another.Objective-C基于C添加nil,nil是一个nothing的对象指针。虽然在语义上了不同于NULL,他们是等效的在另一方面。
On the framework level, Foundation defines the NSNull class, which defines a single class method, +null, which returns a singleton NSNull instance. NSNull is different from nil or NULL, in that it is an actual object, rather than a zero value.
Additionally, in Foundation/NSObjCRuntime.h, Nil is defined as a class pointer to nothing. This lesser-known title- case cousin of nil doesn't show up much very often, but it's at least worth noting. 另外,在Foundation/NSObjCRuntime.h里面,Nil是一个nothing的类的指针。