forked from pmougin/F-Script
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathFSInspectorUniquier.m
42 lines (34 loc) · 1.03 KB
/
FSInspectorUniquier.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
// FSInspectorUniquier.m Copyright (c) 2005-2009 Philippe Mougin.
// This software is open source. See the license.
#import "FSInspectorUniquier.h"
static NSMutableArray *inspectedObjects;
static NSMutableArray *inspectors;
@implementation FSInspectorUniquier
+ (void)initialize
{
static BOOL tooLate = NO;
if ( !tooLate )
{
inspectedObjects = [[NSMutableArray alloc] init];
inspectors = [[NSMutableArray alloc] init];
tooLate = YES;
}
}
+ (void)addObject:(id)inspectedObject inspector:(id)inspector
{
[inspectedObjects addObject:inspectedObject];
[inspectors addObject:inspector];
}
+ (id)inspectorForObject:(id)inspectedObject
{
NSUInteger index = [inspectedObjects indexOfObject:inspectedObject];
if (index == NSNotFound) return nil;
else return [inspectors objectAtIndex:index];
}
+ (void)removeEntryForInspector:(id)inspector
{
NSUInteger index = [inspectors indexOfObject:inspector];
[inspectors removeObjectAtIndex:index];
[inspectedObjects removeObjectAtIndex:index];
}
@end