-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathSSYDictionaryDebugger.m
103 lines (79 loc) · 2.09 KB
/
SSYDictionaryDebugger.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#import "SSYDictionaryDebugger.h"
#ifdef SSY_DEBUGGING_MUTABLE_DICTIONARY_INCLUDED
@implementation SSYDebuggingMutableDictionary
- (id) init
{
self = [super init];
if (self != nil) {
dic = [[NSMutableDictionary alloc] init] ;
}
#if SSY_DEBUGGING_MUTABLE_DICTIONARY_LOG_MEMORY_MANAGEMENT
NSLog(@"info %p has been initted", self) ;
#endif
return self;
}
- (NSString*)description {
return [dic description] ;
}
- (id)forwardingTargetForSelector:(SEL)sel {
return dic ;
}
- (void)setValue:(id)value
forUndefinedKey:key {
[dic setValue:value
forKey:key] ;;
}
- (void)dealloc {
#if SSY_DEBUGGING_MUTABLE_DICTIONARY_LOG_MEMORY_MANAGEMENT
NSLog(@"info %p is being deallocced", self) ;
#endif
[dic release] ;
[super dealloc] ;
}
#if SSY_DEBUGGING_MUTABLE_DICTIONARY_LOG_MEMORY_MANAGEMENT
- (id)retain {
id x = [super retain] ;
NSLog(@"info %p retained to %ld by %@", self, (long)[self retainCount], SSYDebugCaller()) ;
return x ;
}
- (id)autorelease {
id x = [super autorelease] ;
NSLog(@"info %p autoreleased by %@", self, SSYDebugCaller()) ;
return x ;
}
- (oneway void)release {
NSInteger rc = [self retainCount] ;
[super release] ;
NSLog(@"info %p released fr %ld by %@", self, (long)rc, SSYDebugCaller()) ;
}
#endif
#if SSY_DEBUGGING_MUTABLE_DICTIONARY_LOG_CONTENTS_CHANGED
- (void)setValue:(id)value forKey:(NSString *)key {
NSLog(@"12686-01 %s", __PRETTY_FUNCTION__) ;
NSLog(@" key=%@", key) ;
NSLog(@" value=%@", value) ;
if (!value) {
NSLog(@"An object is being removed!") ;
}
[dic setValue:value forKey:key] ;
}
- (void)removeObjectForKey:(id)aKey{
NSLog(@"12686-02 %s", __PRETTY_FUNCTION__) ;
NSLog(@"An object is being removed!") ;
NSLog(@" key=%@", aKey) ;
[dic removeObjectForKey:aKey] ;
}
- (void)removeAllObjects{
NSLog(@"12686-03 %s", __PRETTY_FUNCTION__) ;
NSLog(@"An object is being removed!") ;
[dic removeAllObjects] ;
}
- (void)setObject:(id)anObject forKey:(id)aKey{
NSLog(@"12686-04 %s", __PRETTY_FUNCTION__) ;
NSLog(@" key=%@", aKey) ;
NSLog(@" value=%@", anObject) ;
[dic setObject:anObject forKey:aKey] ;
}
#endif
@end
#endif