summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabian Guerra <fabian.guerra@mapbox.com>2018-09-13 14:55:36 -0700
committerFabian Guerra <fabian.guerra@mapbox.com>2018-09-13 15:42:02 -0700
commit2b70e590c43a911c14de6084c338158f9e7975d9 (patch)
treed1d51cd92d57f5027c5e3dbf45847f8bb1d92c5b
parent14ba3932123e6a2c25843756ec372388ffc61b89 (diff)
downloadqtlocation-mapboxgl-2b70e590c43a911c14de6084c338158f9e7975d9.tar.gz
[ios, macos] Fix packs update KVO notifications.
-rw-r--r--platform/darwin/src/MGLOfflineStorage.mm7
1 files changed, 4 insertions, 3 deletions
diff --git a/platform/darwin/src/MGLOfflineStorage.mm b/platform/darwin/src/MGLOfflineStorage.mm
index f6ec28a7ce..ba4de246f7 100644
--- a/platform/darwin/src/MGLOfflineStorage.mm
+++ b/platform/darwin/src/MGLOfflineStorage.mm
@@ -295,17 +295,18 @@ const MGLExceptionName MGLUnsupportedRegionTypeException = @"MGLUnsupportedRegio
}
id mutablePacks = [strongSelf mutableArrayValueForKey:@"packs"];
+ NSMutableIndexSet *replaceIndexSet = [NSMutableIndexSet indexSet];
[strongSelf.packs enumerateObjectsUsingBlock:^(MGLOfflinePack * _Nonnull pack, NSUInteger idx, BOOL * _Nonnull stop) {
MGLOfflinePack *newPack = packsByIdentifier[@(pack.mbglOfflineRegion->getID())];
if (newPack) {
MGLOfflinePack *previousPack = [mutablePacks objectAtIndex:idx];
[previousPack invalidate];
- [mutablePacks replaceObjectAtIndex:idx withObject:newPack];
- packsByIdentifier[@(newPack.mbglOfflineRegion->getID())] = nil;
+ [replaceIndexSet addIndex:idx];
+ [packsByIdentifier removeObjectForKey:@(newPack.mbglOfflineRegion->getID())];
}
}];
-
+ [mutablePacks replaceObjectsAtIndexes:replaceIndexSet withObjects:packs];
[mutablePacks addObjectsFromArray:packsByIdentifier.allValues];
}
if (completion) {