Skip to content

Commit

Permalink
code and perfomance optimaized
Browse files Browse the repository at this point in the history
  • Loading branch information
shahas committed Jun 5, 2017
1 parent d868bf8 commit f08a5e1
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 15 deletions.
2 changes: 1 addition & 1 deletion BlueShift-iOS-SDK/BatchEventEntity.m
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ - (void)insertEntryParametersList:(NSArray *)parametersArray andNextRetryTimeSta
[context performBlock:^{
NSError *error = nil;
[context save:&error];
[masterContext performBlockAndWait:^{
[masterContext performBlock:^{
NSError *error = nil;
[masterContext save:&error];
}];
Expand Down
28 changes: 15 additions & 13 deletions BlueShift-iOS-SDK/BlueShiftHttpRequestBatchUpload.m
Original file line number Diff line number Diff line change
Expand Up @@ -75,19 +75,9 @@ + (void)createBatches {
}

@try {
if(context && [context isKindOfClass:[NSManagedObjectContext class]]) {
[context performBlock:^{
if(masterContext && [masterContext isKindOfClass:[NSManagedObjectContext class]]) {
[masterContext deleteObject:operationEntityToBeExecuted];
NSError *saveError = nil;
[context save:&saveError];
[masterContext performBlock:^{
NSError *saveError = nil;
if (masterContext && [masterContext isKindOfClass:[NSManagedObjectContext class]]) {
[masterContext save:&saveError];
}
}];
}
if(masterContext && [masterContext isKindOfClass:[NSManagedObjectContext class]]) {
[masterContext performBlockAndWait:^{
[masterContext deleteObject:operationEntityToBeExecuted];
}];
}
}
Expand All @@ -99,6 +89,18 @@ + (void)createBatches {
[self createBatch:paramsArray];
}
}
if (context && [context isKindOfClass:[NSManagedObjectContext class]]) {
[context performBlock:^{
NSError *saveError = nil;
[context save:&saveError];
[masterContext performBlock:^{
NSError *saveError = nil;
if (masterContext && [masterContext isKindOfClass:[NSManagedObjectContext class]]) {
[masterContext save:&saveError];
}
}];
}];
}
}
}
}];
Expand Down
2 changes: 1 addition & 1 deletion BlueShift-iOS-SDK/HttpRequestOperationEntity.m
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ - (void)insertEntryWithMethod:(BlueShiftHTTPMethod)httpMethod andParameters:(NSD
[context performBlock:^{
NSError *error = nil;
[context save:&error];
[masterContext performBlockAndWait:^{
[masterContext performBlock:^{
NSError *error = nil;
[masterContext save:&error];
}];
Expand Down

0 comments on commit f08a5e1

Please sign in to comment.