diff options
author | Minh Nguyễn <mxn@1ec5.org> | 2016-03-07 03:25:21 -0800 |
---|---|---|
committer | Minh Nguyễn <mxn@1ec5.org> | 2016-03-10 17:08:58 -0800 |
commit | 8824237e2df9d9bfb9cd618e762e74d8ab08c099 (patch) | |
tree | 58cc45ca983cb487606b185d99a2de2b6a089703 /platform/darwin/src/MGLOfflineStorage.mm | |
parent | 0348c1ee967cf3e19d9dc91918d28e42b40b5b19 (diff) | |
download | qtlocation-mapboxgl-8824237e2df9d9bfb9cd618e762e74d8ab08c099.tar.gz |
[ios, osx] Documented offline APIs
Also categorized offline symbols for jazzy and moved styleURL from MGLOfflineRegion to MGLTilePyramidOfflineRegion, since you never know if there will be a region type not constrained by a style in the future.
Diffstat (limited to 'platform/darwin/src/MGLOfflineStorage.mm')
-rw-r--r-- | platform/darwin/src/MGLOfflineStorage.mm | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/platform/darwin/src/MGLOfflineStorage.mm b/platform/darwin/src/MGLOfflineStorage.mm index 17537452a3..f2061b4a3f 100644 --- a/platform/darwin/src/MGLOfflineStorage.mm +++ b/platform/darwin/src/MGLOfflineStorage.mm @@ -76,7 +76,7 @@ } } -- (void)addTaskForRegion:(id <MGLOfflineRegion>)region withContext:(NSData *)context completionHandler:(MGLOfflineTaskRegistrationCompletionHandler)completion { +- (void)addTaskForRegion:(id <MGLOfflineRegion>)region withContext:(NSData *)context completionHandler:(MGLOfflineTaskAdditionCompletionHandler)completion { if (![region conformsToProtocol:@protocol(MGLOfflineRegion_Private)]) { [NSException raise:@"Unsupported region type" format: @"Regions of type %@ are unsupported.", NSStringFromClass([region class])]; @@ -95,7 +95,7 @@ } : nil]; } if (completion) { - MGLOfflineTask *task = [[MGLOfflineTask alloc] initWithMBGLRegion:new mbgl::OfflineRegion(std::move(*mbglOfflineRegion))]; + MGLOfflineTask *task = mbglOfflineRegion ? [[MGLOfflineTask alloc] initWithMBGLRegion:new mbgl::OfflineRegion(std::move(*mbglOfflineRegion))] : nil; dispatch_async(dispatch_get_main_queue(), [&, completion, error, task](void) { completion(task, error); }); @@ -104,7 +104,7 @@ } - (void)removeTask:(MGLOfflineTask *)task withCompletionHandler:(MGLOfflineTaskRemovalCompletionHandler)completion { - self.mbglFileSource->deleteOfflineRegion(std::move(*task.mbglOfflineRegion), [&, completion](std::exception_ptr exception) { + self.mbglFileSource->deleteOfflineRegion(std::move(*task.mbglOfflineRegion), [&, task, completion](std::exception_ptr exception) { NSError *error; if (exception) { error = [NSError errorWithDomain:MGLErrorDomain code:-1 userInfo:@{ @@ -112,14 +112,15 @@ }]; } if (completion) { - dispatch_async(dispatch_get_main_queue(), [&, completion, error](void) { + dispatch_async(dispatch_get_main_queue(), [&, task, completion, error](void) { + [task invalidate]; completion(error); }); } }); } -- (void)getTasksWithCompletionHandler:(MGLOfflineTasksRetrievalCompletionHandler)completion { +- (void)getTasksWithCompletionHandler:(MGLOfflineTaskListingCompletionHandler)completion { self.mbglFileSource->listOfflineRegions([&, completion](std::exception_ptr exception, mbgl::optional<std::vector<mbgl::OfflineRegion>> regions) { NSError *error; if (exception) { |