首页 > 其他 > 详细

Objective C中nil/Nil/NULL的区别

时间:2015-09-27 18:42:29      阅读:137      评论:0      收藏:0      [点我收藏+]

nil:指向oc中对象的空指针

Nil:指向oc中类的空指针

NULL:指向其他类型的空指针,如一个c类型的内存指针

NSNull:在集合对象中,表示空值的对象

 

若obj为nil:[obj message]将返回NO,而不是NSException

若obj为NSNull:[obj message]将抛出异常NSException

 

下面是官方文档的解释:

nil

Defines the id of a null instance.

Available in iOS 4.0 and later.

 

Nil

Defines the id of a null class.

Available in iOS 4.0 and later.

 

NSNull

The NSNull class defines a singleton object used to represent null values in collection objects (which don’t allow nil values).(NSNull类定义了一个单例对象用于表示null值的集合对象(不允许零值)。)

Returns the singleton instance of NSNull.(NSNull返回单例实例。)

 

Objective C中nil/Nil/NULL的区别

原文:http://www.cnblogs.com/zzq1580443149/p/4842518.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!