summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
Diffstat (limited to 'platform')
-rw-r--r--platform/darwin/src/MGLOfflineStorage.h11
-rw-r--r--platform/darwin/src/MGLOfflineStorage.mm5
-rw-r--r--platform/ios/app/MBXViewController.m12
3 files changed, 14 insertions, 14 deletions
diff --git a/platform/darwin/src/MGLOfflineStorage.h b/platform/darwin/src/MGLOfflineStorage.h
index d646e77583..a6b7de4289 100644
--- a/platform/darwin/src/MGLOfflineStorage.h
+++ b/platform/darwin/src/MGLOfflineStorage.h
@@ -171,9 +171,8 @@ typedef NS_ENUM(NSUInteger, MGLResourceKind) {
/**
MGLOfflineStorage implements a singleton (shared object) that manages offline
- packs. All of this class’s instance methods are asynchronous, reflecting the
- fact that offline resources are stored in a database. The shared object
- maintains a canonical collection of offline packs in its `packs` property.
+ packs and ambient caching. All of this class’s instance methods are asynchronous,
+ reflecting the fact that offline resources are stored in a database. The shared object maintains a canonical collection of offline packs in its `packs` property.
#### Related examples
See the <a href="https://docs.mapbox.com/ios/maps/examples/offline-pack/">
@@ -303,7 +302,7 @@ MGL_EXPORT
*/
- (void)removePack:(MGLOfflinePack *)pack withCompletionHandler:(nullable MGLOfflinePackRemovalCompletionHandler)completion;
-- (void)invalidateOfflineRegionForPack:(MGLOfflinePack *)pack withCompletionHandler:(void (^)(NSError * _Nullable))completion;
+- (void)invalidatePack:(MGLOfflinePack *)pack withCompletionHandler:(void (^)(NSError * _Nullable))completion;
/**
Forcibly, asynchronously reloads the `packs` property. At some point after this
method is called, the pointer values of the `MGLOfflinePack` objects in the
@@ -348,9 +347,9 @@ MGL_EXPORT
// JK FINISH DOC
/*
- Sets the maximum ambient cache size in megabytes. The default maximum cache size is _ MB. To disable ambient caching, set the maximum ambient cache size to 0. Setting the maximum ambient cache size does not impact the maximum size for offline packs.
+ Sets the maximum ambient cache size in megabytes. The default maximum cache size is 50 MB. To disable ambient caching, set the maximum ambient cache size to 0. Setting the maximum ambient cache size does not impact the maximum size for offline packs.
- This method should be called before using the database.
+ This method should be called before creating the database.
*/
- (void)setMaximumAmbientCacheSize:(NSInteger)cacheSize withCallback:(void (^)(NSError *_Nullable error))completion;
diff --git a/platform/darwin/src/MGLOfflineStorage.mm b/platform/darwin/src/MGLOfflineStorage.mm
index f84db344b5..d372c1e439 100644
--- a/platform/darwin/src/MGLOfflineStorage.mm
+++ b/platform/darwin/src/MGLOfflineStorage.mm
@@ -69,6 +69,9 @@ const MGLExceptionName MGLUnsupportedRegionTypeException = @"MGLUnsupportedRegio
return sharedOfflineStorage;
}
+//- (NSInteger)maximumAmbientCacheSize {
+// return _
+//}
#if TARGET_OS_IPHONE || TARGET_OS_SIMULATOR
- (void)pauseFileSource:(__unused NSNotification *)notification {
if (self.isPaused) {
@@ -446,7 +449,7 @@ const MGLExceptionName MGLUnsupportedRegionTypeException = @"MGLUnsupportedRegio
}
-- (void)invalidateOfflineRegionForPack:(MGLOfflinePack *)pack withCompletionHandler:(void (^)(NSError * _Nullable))completion {
+- (void)invalidatePack:(MGLOfflinePack *)pack withCompletionHandler:(void (^)(NSError * _Nullable))completion {
if (!completion) { return; }
mbgl::OfflineRegion& region = *pack.mbglOfflineRegion;
diff --git a/platform/ios/app/MBXViewController.m b/platform/ios/app/MBXViewController.m
index 032852d08f..3f54a5672f 100644
--- a/platform/ios/app/MBXViewController.m
+++ b/platform/ios/app/MBXViewController.m
@@ -1785,14 +1785,14 @@ CLLocationCoordinate2D randomWorldCoordinate() {
return filePath;
}
-// Getting a bad access exception
- (void)invalidateAmbientCache {
unsigned long long fileSize = [self getCacheSize];
NSLog(@"STARTING WITH CACHE SIZE: %llu", fileSize);
[[MGLOfflineStorage sharedOfflineStorage] invalidateAmbientCacheWithCompletion:^(NSError * _Nullable error) {
unsigned long long newFileSize = [self getCacheSize];
- NSLog(@"\nAmbient cache has been reloaded!CACHE SIZE: %llu", newFileSize);
+ NSLog(@"Ambient cache has been reloaded!\nCACHE SIZE: %llu", newFileSize);
}];
+ [[MGLOfflineStorage sharedOfflineStorage] setMaximumAllowedMapboxTiles:40];
}
- (void)resetDatabase {
@@ -1831,11 +1831,9 @@ CLLocationCoordinate2D randomWorldCoordinate() {
error:nil];
NSBundle *bundleIdentifier = [[NSBundle mainBundle] bundleIdentifier];
-
- // Can I do this in
- cacheDirectoryURL = [cacheDirectoryURL URLByAppendingPathComponent:bundleIdentifier];
- cacheDirectoryURL = [cacheDirectoryURL URLByAppendingPathComponent:@".mapbox/cache.db"];
-// cacheDirectoryURL = [cacheDirectoryURL URLByAppendingPathComponent:@""];
+
+ NSString *urlString = [NSString stringWithFormat:@"%@/.mapbox/cache.db", bundleIdentifier];
+ cacheDirectoryURL = [cacheDirectoryURL URLByAppendingPathComponent:urlString];
NSString *path = cacheDirectoryURL.path;
return [[manager attributesOfItemAtPath:path error:nil] fileSize];
}