Skip to content
This repository has been archived by the owner on May 9, 2018. It is now read-only.

Possible problems with _mapScrollView.delegate #634

Open
chchrn opened this issue May 20, 2015 · 1 comment
Open

Possible problems with _mapScrollView.delegate #634

chchrn opened this issue May 20, 2015 · 1 comment

Comments

@chchrn
Copy link

chchrn commented May 20, 2015

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.

@vzqwer
Copy link

vzqwer commented Aug 13, 2015

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;
    }
    // !!!
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants