Skip to content

Commit

Permalink
some safe checks when searlizing events
Browse files Browse the repository at this point in the history
  • Loading branch information
ijunaid committed Oct 3, 2024
1 parent 82e0b1a commit fd4d827
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions CountlyPersistency.m
Original file line number Diff line number Diff line change
Expand Up @@ -282,23 +282,27 @@ - (void)recordEvent:(CountlyEvent *)event

- (NSString *)serializedRecordedEvents
{
NSMutableArray* tempArray = NSMutableArray.new;

NSMutableArray *tempArray = NSMutableArray.new;
@synchronized (self.recordedEvents)
{
if (self.recordedEvents.count == 0)
return nil;

for (CountlyEvent* event in self.recordedEvents.copy)

NSArray *eventsCopy = self.recordedEvents.copy;

for (CountlyEvent *event in eventsCopy)
{
[tempArray addObject:[event dictionaryRepresentation]];
[self.recordedEvents removeObject:event];
}

[self.recordedEvents removeObjectsInArray:eventsCopy];
}

return [tempArray cly_JSONify];
}


- (void)flushEvents
{
@synchronized (self.recordedEvents)
Expand Down

0 comments on commit fd4d827

Please sign in to comment.