From caef1785eb8bb5471ccfbd6a8327888513818134 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguye=CC=82=CC=83n?= Date: Sat, 12 Mar 2016 11:32:52 -0800 Subject: [PATCH] [ios, osx] Removed pack nil check from MGLOfflineRegionObserver Due to ARC, MGLOfflinePack can be deallocated at any time following its initialization. -dealloc ensures that the offline region observer is unset, but that step is asynchronous; there is no guarantee that it completes before the first status change update. In fact, the pack is deallocated before the first status change update unless it is captured outside of the MGLOfflinePackAdditionCompletionHandler. The pack nil check is unnecessary because the subsequent code would be a no-op. --- platform/darwin/src/MGLOfflinePack.mm | 6 ------ 1 file changed, 6 deletions(-) diff --git a/platform/darwin/src/MGLOfflinePack.mm b/platform/darwin/src/MGLOfflinePack.mm index c6e483e6d..42bd871e5 100644 --- a/platform/darwin/src/MGLOfflinePack.mm +++ b/platform/darwin/src/MGLOfflinePack.mm @@ -189,16 +189,12 @@ NSError *MGLErrorFromResponseError(mbgl::Response::Error error) { void MBGLOfflineRegionObserver::statusChanged(mbgl::OfflineRegionStatus status) { dispatch_async(dispatch_get_main_queue(), ^{ - NSCAssert(pack, @"MBGLOfflineRegionObserver is dangling without an associated MGLOfflinePack."); - [pack offlineRegionStatusDidChange:status]; }); } void MBGLOfflineRegionObserver::responseError(mbgl::Response::Error error) { dispatch_async(dispatch_get_main_queue(), ^{ - NSCAssert(pack, @"MBGLOfflineRegionObserver is dangling without an associated MGLOfflinePack."); - if ([pack.delegate respondsToSelector:@selector(offlinePack:didReceiveError:)]) { [pack.delegate offlinePack:pack didReceiveError:MGLErrorFromResponseError(error)]; } @@ -207,8 +203,6 @@ void MBGLOfflineRegionObserver::responseError(mbgl::Response::Error error) { void MBGLOfflineRegionObserver::mapboxTileCountLimitExceeded(uint64_t limit) { dispatch_async(dispatch_get_main_queue(), ^{ - NSCAssert(pack, @"MBGLOfflineRegionObserver is dangling without an associated MGLOfflinePack."); - if ([pack.delegate respondsToSelector:@selector(offlinePack:didReceiveMaximumAllowedMapboxTiles:)]) { [pack.delegate offlinePack:pack didReceiveMaximumAllowedMapboxTiles:limit]; }