forked from rentzsch/MiscMerge
-
Notifications
You must be signed in to change notification settings - Fork 0
/
NSNull.m
executable file
·57 lines (42 loc) · 1.35 KB
/
NSNull.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
//
// NSNull.m
//
// Written by Doug McClure
//
// Copyright 2002-2004 by Don Yacktman and Doug McClure.
// All rights reserved.
//
// This notice may not be removed from this source code.
//
// This header is included in the MiscKit by permission from the author
// and its use is governed by the MiscKit license, found in the file
// "License.rtf" in the MiscKit distribution. Please refer to that file
// for a list of all applicable permissions and restrictions.
//
#import "NSNull.h"
#import <limits.h>
#import <Foundation/NSString.h>
#if !HAVE_NSNULL
static NSNull *_instance;
@implementation NSNull
+ (id)null
{
if ( _instance == nil )
_instance = [(id)NSAllocateObject([NSNull class], 0, NULL) init];
return _instance;
}
+ (id)allocWithZone:(NSZone *)zone { return [self null]; }
- (void)dealloc {}
- (id)description { return @"<null>"; }
- (id)retain { return self; }
- (oneway void)release {}
- (id)autorelease { return self; }
- (unsigned)retainCount { return UINT_MAX; }
- (id)copyWithZone:(NSZone *)zone { return self; };
- (id)copy { return self; };
- (void)encodeWithCoder:(NSCoder *)aCoder {}
- (id)initWithCoder:(NSCoder *)aDecoder { return self; }
- (id)replacementObjectForCoder:(NSCoder *)aCoder { return self; }
- (id)valueForKey:(NSString *)key { return nil; }
@end
#endif