-
Notifications
You must be signed in to change notification settings - Fork 1
/
EventTracer.m
executable file
·139 lines (116 loc) · 3.48 KB
/
EventTracer.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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
//
// EventTracer.m
// EventTracer
//
// Created by vedon on 9/26/15.
// Copyright © 2015 bugtags.com. All rights reserved.
//
#import "EventTracer.h"
#import "EventFootprintSenderInfo.h"
#import "EventFootprintGestureRecognizerInfo.h"
#import "EventFootprintProtocol.h"
#import "EventFootprintTableViewInfo.h"
#define CacheViewHierarchy 1
#define MaxRecordItem 15
@interface EventTracer()
@property (copy,nonatomic) NSString *filePath;
@property (retain,nonatomic) NSMutableArray *footprintVC;
@property (retain,nonatomic) NSArray *currentViewsInfo;
@property (assign,nonatomic) NSUInteger currentGroupIndex;
@end
@implementation EventTracer
+ (instancetype)shareLogger
{
static EventTracer *logger = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
logger = [[EventTracer alloc]init];
});
return logger;
}
- (instancetype)init
{
self = [super init];
if (self) {
self.footprintVC = [NSMutableArray array];
self.currentViewsInfo = [NSArray array];
self.currentGroupIndex = 0;
}
return self;
}
- (void)dealloc
{
[_filePath release];
_filePath = nil;
[_footprintVC release];
_footprintVC = nil;
[_currentViewsInfo release];
_currentViewsInfo = nil;
[super dealloc];
}
#pragma mark - Public
- (void)addFootprintWithSendAction:(SEL)action to:(id)target from:(id)sender forEvent:(UIEvent *)event
{
EventFootprintSenderInfo *senderInfo = [[[EventFootprintSenderInfo alloc]initWithSender:sender receiver:target action:action event:event] autorelease];
assert(senderInfo);
if (senderInfo)
{
[self.footprintVC addObject:senderInfo];
}
[self logFootprint];
}
- (void)addFootprintWithTableView:(UITableView *)table selectedIndexPath:(NSIndexPath *)indexPath
{
EventFootprintTableViewInfo *tableInfo = [[EventFootprintTableViewInfo alloc]initWithTableView:table selectedIndexPath:indexPath];
[self.footprintVC addObject:tableInfo];
[self logFootprint];
}
- (void)addFootprintWithGesture:(UIGestureRecognizer *)gesture
{
EventFootprintGestureRecognizerInfo *gestureInfo = [[[EventFootprintGestureRecognizerInfo alloc]initWithGesture:gesture]autorelease];
[self.footprintVC addObject:gestureInfo];
[self logFootprint];
}
#pragma mark - Utili
- (void)removeActionRecordWithController:(id)object
{
NSInteger removeStartIndex = -1;
for (int i =0; i< self.footprintVC.count ;i++)
{
id senderInfo = [self.footprintVC objectAtIndex:i];
if ([senderInfo isKindOfClass:[EventFootprintSenderInfo class]])
{
removeStartIndex = i;
}else
{
removeStartIndex = -1;
}
}
if (removeStartIndex != -1)
{
[self.footprintVC removeObjectsInRange:NSMakeRange(removeStartIndex, self.footprintVC.count - removeStartIndex)];
}
}
- (void)logFootprint
{
if (self.footprintVC.count > MaxRecordItem + 1)
{
NSRange range = NSMakeRange(MaxRecordItem, self.footprintVC.count - MaxRecordItem);
self.footprintVC = [NSMutableArray arrayWithArray:[self.footprintVC subarrayWithRange:range]];
}
printf("\n\n\n");
NSLog(@"*********************************");
for (id<EventFootprintProtocol> object in self.footprintVC)
{
NSLog(@"%@",[object objectName]);
}
NSLog(@"*********************************");
}
#pragma mark - Getter && Setter
- (NSString *)filePath
{
if (!_filePath) {
}
return _filePath;
}
@end