Nil nil, NULL, NSNull, kCFNull difference

  • Nil Objective-C instance object pointer null: NSSring * STR = nil;
#define nil ((void*)0)
Copy the code
  • Nil: Class Class = Nil;
#define nil ((void*)0)
Copy the code
  • Char *p = NULL;
#define NULL ((void*)0)
Copy the code
  • NSNull is an Objective-C class that inherits NSObject, mostly used for null values in array dictionaries
@interface NSNull : NSObject <NSCopying, NSSecureCoding>
+ (NSNull *)null;
@end
Copy the code
  • KCFNull is a singleton of NSNull [NSNull null]
typedef const struct CF_BRIDGED_TYPE(NSNull) __CFNull * CFNullRef;
const CFNullRef kCFNull;    // the singleton null instance
Copy the code