博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

关于nil,Nil,NULL区别

Posted on 2012-12-26 17:44  酸梅拯救地球  阅读(210)  评论(0)    收藏  举报

转自http://blog.csdn.net/yhawaii/article/details/7442529

nil: A null pointer to an Objective-C object.
( #define nil ((id)0)  )

Nil: A null pointer to an Objective-C class.

NULL: A null pointer to anything else,  is for C-style memory pointers.
( #define NULL ((void *)0)  )


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.

 

1.NSArray这样的类型,nil或NULL不能添加到其中,可以用 [NSNull null] 返回的对象来代替.(NSArray 已nil作为标识符)