Skip to content

Commit

Permalink
feat: 防止数组遍历时增删操作,发布3.1.0-beta版本
Browse files Browse the repository at this point in the history
  • Loading branch information
CaicaiNo authored and lvyuqiang committed Apr 6, 2021
1 parent f7ddd92 commit 2e7e70b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
2 changes: 1 addition & 1 deletion GrowingAnalytics.podspec
Expand Up @@ -8,7 +8,7 @@

Pod::Spec.new do |s|
s.name = 'GrowingAnalytics'
s.version = '3.0.2'
s.version = '3.1.0-beta'
s.summary = 'iOS SDK of GrowingIO.'
s.description = <<-DESC
GrowingAnalytics具备自动采集基本的用户行为事件,比如访问和行为数据等。目前支持代码埋点、无埋点、可视化圈选、热图等功能。
Expand Down
Expand Up @@ -64,7 +64,6 @@ @interface GrowingMobileDebugger () <GrowingSRWebSocketDelegate,
//表示web和app是否同时准备好数据发送,此时表示可以发送数据
@property (nonatomic, assign) BOOL isReady;
@property (nonatomic, strong) NSMutableArray * cacheArray;
@property (nonatomic, assign) BOOL isShouldCache;
@property (nonatomic, strong) NSMutableArray * cacheEvent;
@property (nonatomic, strong) NSTimer *timer;
@property (nonatomic, retain) GrowingStatusBar *statusWindow;
Expand Down Expand Up @@ -104,7 +103,6 @@ + (BOOL)isRunning {
}

- (void)runWithMobileDebugger:(NSURL *)url{
self.isShouldCache = YES;
[[GrowingEventManager shareInstance] addInterceptor:self];


Expand Down Expand Up @@ -265,16 +263,18 @@ - (void)nextOne {
}

if (self.cacheEvent.count > 0) {
for (int i = 0; i < self.cacheEvent.count; i++) {
NSMutableDictionary *attrs = [[NSMutableDictionary alloc] initWithDictionary:self.cacheEvent[i]];
//防止遍历的时候进行增删改查
LOCK(NSArray *events = self.cacheEvent.copy;
[self.cacheEvent removeAllObjects];);
for (int i = 0; i < events.count; i++) {
NSMutableDictionary *attrs = [[NSMutableDictionary alloc] initWithDictionary:events[i]];
NSMutableDictionary *cacheDic = [NSMutableDictionary dictionary];
cacheDic[@"msgType"] = @"debugger_data";
cacheDic[@"sdkVersion"] = GrowingTrackerVersionName;
LOCK(cacheDic[@"data"] = attrs;
cacheDic[@"data"][@"url"] = [[self class] absoluteURL]);
cacheDic[@"data"] = attrs;
cacheDic[@"data"][@"url"] = [[self class] absoluteURL];
[self sendJson:cacheDic];
}
[self.cacheEvent removeAllObjects];
}
}

Expand Down Expand Up @@ -397,7 +397,6 @@ - (void)webSocket:(GrowingSRWebSocket *)webSocket
wasClean:(BOOL)wasClean {
GIOLogDebug(@"已断开链接");
_isReady = NO;
_isShouldCache = NO;
if (code != GrowingSRStatusCodeNormal) {
[self _stopWithError:@"当前设备已与Web端断开连接,如需继续调试请扫码重新连接。"];
}
Expand All @@ -406,7 +405,6 @@ - (void)webSocket:(GrowingSRWebSocket *)webSocket
- (void)webSocket:(GrowingSRWebSocket *)webSocket didFailWithError:(NSError *)error {
GIOLogDebug(@"error : %@", error);
_isReady = NO;
_isShouldCache = NO;
[self _stopWithError:@"服务器链接失败"];
}

Expand Down

0 comments on commit 2e7e70b

Please sign in to comment.