_ASTableViewProxy & _ASCollectionViewProxy fixes.

These weren't correctly handling teardown:  nilling the `asyncDelegate`
created a new selector-forwarding NSProxy that crashed and burned
because there was nowhere to forward to.  Nil everything correctly.

Tentatively fixes #121.
This commit is contained in:
Nadine Salter
2014-12-04 16:28:04 -08:00
parent 16445cfd5d
commit 764650fb94
2 changed files with 38 additions and 14 deletions

View File

@@ -139,20 +139,32 @@ static BOOL _isInterceptedSelector(SEL sel)
{
if (_asyncDataSource == asyncDataSource)
return;
_asyncDataSource = asyncDataSource;
_proxyDataSource = [[_ASCollectionViewProxy alloc] initWithTarget:_asyncDataSource interceptor:self];
super.dataSource = (id<UICollectionViewDataSource>)_proxyDataSource;
if (asyncDataSource == nil) {
_asyncDataSource = nil;
_proxyDataSource = nil;
super.dataSource = nil;
} else {
_asyncDataSource = asyncDataSource;
_proxyDataSource = [[_ASCollectionViewProxy alloc] initWithTarget:_asyncDataSource interceptor:self];
super.dataSource = (id<UICollectionViewDataSource>)_proxyDataSource;
}
}
- (void)setAsyncDelegate:(id<ASCollectionViewDelegate>)asyncDelegate
{
if (_asyncDelegate == asyncDelegate)
return;
_asyncDelegate = asyncDelegate;
_proxyDelegate = [[_ASCollectionViewProxy alloc] initWithTarget:_asyncDelegate interceptor:self];
super.delegate = (id<UICollectionViewDelegate>)_proxyDelegate;
if (asyncDelegate == nil) {
_asyncDelegate = nil;
_proxyDelegate = nil;
super.delegate = nil;
} else {
_asyncDelegate = asyncDelegate;
_proxyDelegate = [[_ASCollectionViewProxy alloc] initWithTarget:_asyncDelegate interceptor:self];
super.delegate = (id<UICollectionViewDelegate>)_proxyDelegate;
}
}
- (ASRangeTuningParameters)rangeTuningParameters

View File

@@ -149,9 +149,15 @@ static BOOL _isInterceptedSelector(SEL sel)
if (_asyncDataSource == asyncDataSource)
return;
_asyncDataSource = asyncDataSource;
_proxyDataSource = [[_ASTableViewProxy alloc] initWithTarget:_asyncDataSource interceptor:self];
super.dataSource = (id<UITableViewDataSource>)_proxyDataSource;
if (asyncDataSource == nil) {
_asyncDataSource = nil;
_proxyDataSource = nil;
super.dataSource = nil;
} else {
_asyncDataSource = asyncDataSource;
_proxyDataSource = [[_ASTableViewProxy alloc] initWithTarget:_asyncDataSource interceptor:self];
super.dataSource = (id<UITableViewDataSource>)_proxyDataSource;
}
}
- (void)setAsyncDelegate:(id<ASTableViewDelegate>)asyncDelegate
@@ -159,9 +165,15 @@ static BOOL _isInterceptedSelector(SEL sel)
if (_asyncDelegate == asyncDelegate)
return;
_asyncDelegate = asyncDelegate;
_proxyDelegate = [[_ASTableViewProxy alloc] initWithTarget:_asyncDelegate interceptor:self];
super.delegate = (id<UITableViewDelegate>)_proxyDelegate;
if (asyncDelegate == nil) {
_asyncDelegate = nil;
_proxyDelegate = nil;
super.delegate = nil;
} else {
_asyncDelegate = asyncDelegate;
_proxyDelegate = [[_ASTableViewProxy alloc] initWithTarget:_asyncDelegate interceptor:self];
super.delegate = (id<UITableViewDelegate>)_proxyDelegate;
}
}
- (ASRangeTuningParameters)rangeTuningParameters