主要就如下几点:html
一、nil:通常赋值给空对象;spa
二、NULL:通常赋值给nil以外的其余空值。如SEL等;指针
举个栗子(好重啊~):htm
[NSApp beginSheet:sheet
modalForWindow:mainWindow对象
modalDelegate:nil //pointing to an objectblog
didEndSelector:NULL //pointing to a non object/classget
contextInfo:NULL]; //pointing to a non object/classio
三、NSNULL:NSNull只有一个方法:+ (NSNull *) null;class
[NSNull null]用来在NSArray和NSDictionary中加入非nil(表示列表结束)的空值.泛型
四、当向nil发送消息时,返回NO,不会有异常,程序将继续执行下去;
而向NSNull的对象发送消息时会收到异常。
-------------------------
如下转载自:http://blog.sina.com.cn/s/blog_722017670100v2b4.html
nil: A null pointer to an Objective-C object. ( #define nil ((id)0) )
nil 是一个对象值。
Nil: A null pointer to an Objective-C class.
NULL: A null pointer to anything else. ( #define NULL ((void *)0) )
NULL是一个通用指针(泛型指针)。
NSNull: A class defines a singleton object used to represent null values in collection objects (which don't allow nil values).
[NSNull null]: The singleton instance of NSNull.
[NSNull null]是一个对象,他用在不能使用nil的场合。
由于在NSArray和NSDictionary中nil中有特殊的含义(表示列表结束),因此不能在集合中放入nil值。如要确实须要存储一个表示“什么都没有”的值,能够使用NSNull类。NSNull只有一个方法:
+ (NSNull *) null;