DEPRECATED-mapbox-ios-sdk
DEPRECATED-mapbox-ios-sdk copied to clipboard
Possible problems with _mapScrollView.delegate
I think this is not safety:
- (void)createMapView
{
...
_mapScrollView = [[RMMapScrollView alloc] initWithFrame:self.bounds];
_mapScrollView.delegate = self;
...
}
- (void)dealloc
{
[_moveDelegateQueue cancelAllOperations];
[_zoomDelegateQueue cancelAllOperations];
[[NSNotificationCenter defaultCenter] removeObserver:self];
[_mapScrollView removeObserver:self forKeyPath:@"contentOffset"];
[_tileSourcesContainer cancelAllDownloads];
_locationManager.delegate = nil;
[_locationManager stopUpdatingLocation];
[_locationManager stopUpdatingHeading];
}
Property "delegate" of UIScrollView is assign, not weak. In dealloc method your didn't set _mapScrollView.delegate to nil. This is a possible problem, because instance of UIScrollView can send a message to dealloced object.
I have a bug with this issue.
I have a class with
@property (nonatomic, weak) IBOutlet RMMapView *mapView;
Possible workaround I've found:
- (void)dealloc
{
[self removeObservers];
self.mapView.delegate = nil;
// !!!: Workaround for https://github.com/mapbox/mapbox-ios-sdk/issues/634 !!!
RMMapScrollView *mapScrollViewPrivate = [self.mapView valueForKey:@"_mapScrollView"];
if (mapScrollViewPrivate)
{
mapScrollViewPrivate.delegate = nil;
}
// !!!
}