Default proxy object for ASTableView and ASCollectionView

fixes #231 #233
This commit is contained in:
Ryan Nystrom
2015-01-20 13:15:39 -08:00
parent 7542f7ca17
commit afb21bf8dd
2 changed files with 13 additions and 21 deletions

View File

@@ -63,7 +63,6 @@ static BOOL _isInterceptedSelector(SEL sel)
return nil; return nil;
} }
ASDisplayNodeAssert(target, @"target must not be nil");
ASDisplayNodeAssert(interceptor, @"interceptor must not be nil"); ASDisplayNodeAssert(interceptor, @"interceptor must not be nil");
_target = target; _target = target;
@@ -126,6 +125,9 @@ static BOOL _isInterceptedSelector(SEL sel)
_dataController.delegate = _rangeController; _dataController.delegate = _rangeController;
_dataController.dataSource = self; _dataController.dataSource = self;
_proxyDelegate = [[_ASCollectionViewProxy alloc] initWithTarget:nil interceptor:self];
super.delegate = (id<UICollectionViewDelegate>)_proxyDelegate;
[self registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:@"_ASCollectionViewCell"]; [self registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:@"_ASCollectionViewCell"];
return self; return self;
@@ -174,16 +176,10 @@ static BOOL _isInterceptedSelector(SEL sel)
if (_asyncDelegate == asyncDelegate) if (_asyncDelegate == asyncDelegate)
return; return;
if (asyncDelegate == nil) {
_asyncDelegate = nil;
_proxyDelegate = nil;
super.delegate = nil;
} else {
_asyncDelegate = asyncDelegate; _asyncDelegate = asyncDelegate;
_proxyDelegate = [[_ASCollectionViewProxy alloc] initWithTarget:_asyncDelegate interceptor:self]; _proxyDelegate = [[_ASCollectionViewProxy alloc] initWithTarget:_asyncDelegate interceptor:self];
super.delegate = (id<UICollectionViewDelegate>)_proxyDelegate; super.delegate = (id<UICollectionViewDelegate>)_proxyDelegate;
} }
}
- (ASRangeTuningParameters)rangeTuningParameters - (ASRangeTuningParameters)rangeTuningParameters
{ {

View File

@@ -63,7 +63,6 @@ static BOOL _isInterceptedSelector(SEL sel)
return nil; return nil;
} }
ASDisplayNodeAssert(target, @"target must not be nil");
ASDisplayNodeAssert(interceptor, @"interceptor must not be nil"); ASDisplayNodeAssert(interceptor, @"interceptor must not be nil");
_target = target; _target = target;
@@ -135,6 +134,9 @@ static BOOL _isInterceptedSelector(SEL sel)
_dataController.dataSource = self; _dataController.dataSource = self;
_dataController.delegate = _rangeController; _dataController.delegate = _rangeController;
_proxyDelegate = [[_ASTableViewProxy alloc] initWithTarget:nil interceptor:self];
super.delegate = (id<UITableViewDelegate>)_proxyDelegate;
return self; return self;
} }
@@ -173,16 +175,10 @@ static BOOL _isInterceptedSelector(SEL sel)
if (_asyncDelegate == asyncDelegate) if (_asyncDelegate == asyncDelegate)
return; return;
if (asyncDelegate == nil) {
_asyncDelegate = nil;
_proxyDelegate = nil;
super.delegate = nil;
} else {
_asyncDelegate = asyncDelegate; _asyncDelegate = asyncDelegate;
_proxyDelegate = [[_ASTableViewProxy alloc] initWithTarget:_asyncDelegate interceptor:self]; _proxyDelegate = [[_ASTableViewProxy alloc] initWithTarget:asyncDelegate interceptor:self];
super.delegate = (id<UITableViewDelegate>)_proxyDelegate; super.delegate = (id<UITableViewDelegate>)_proxyDelegate;
} }
}
- (void)reloadData - (void)reloadData
{ {