From c81f5d08fc0acef286075ac228f435e89621c72e Mon Sep 17 00:00:00 2001 From: Ethan Nagel Date: Mon, 4 May 2015 08:51:25 -0700 Subject: [PATCH] refactor ASTAbleView initialization code so it also gets initialized when starting from initWithCoder: --- AsyncDisplayKit/ASTableView.mm | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/AsyncDisplayKit/ASTableView.mm b/AsyncDisplayKit/ASTableView.mm index 4c2b79ca01..d0a43aad39 100644 --- a/AsyncDisplayKit/ASTableView.mm +++ b/AsyncDisplayKit/ASTableView.mm @@ -129,17 +129,7 @@ static BOOL _isInterceptedSelector(SEL sel) #pragma mark - #pragma mark Lifecycle -- (instancetype)initWithFrame:(CGRect)frame style:(UITableViewStyle)style -{ - return [self initWithFrame:frame style:style asyncDataFetching:NO]; -} - -- (instancetype)initWithFrame:(CGRect)frame style:(UITableViewStyle)style asyncDataFetching:(BOOL)asyncDataFetchingEnabled -{ - - if (!(self = [super initWithFrame:frame style:style])) - return nil; - +- (void)configureWithAsyncDataFetching:(BOOL)asyncDataFetchingEnabled { _layoutController = [[ASFlowLayoutController alloc] initWithScrollOption:ASFlowLayoutDirectionVertical]; _rangeController = [[ASRangeController alloc] init]; @@ -155,6 +145,28 @@ static BOOL _isInterceptedSelector(SEL sel) _leadingScreensForBatching = 1.0; _batchContext = [[ASBatchContext alloc] init]; +} + +- (instancetype)initWithFrame:(CGRect)frame style:(UITableViewStyle)style +{ + return [self initWithFrame:frame style:style asyncDataFetching:NO]; +} + +- (instancetype)initWithFrame:(CGRect)frame style:(UITableViewStyle)style asyncDataFetching:(BOOL)asyncDataFetchingEnabled +{ + if (!(self = [super initWithFrame:frame style:style])) + return nil; + + [self configureWithAsyncDataFetching:asyncDataFetchingEnabled]; + + return self; +} + +- (instancetype)initWithCoder:(NSCoder *)aDecoder { + if (!(self = [super initWithCoder:aDecoder])) + return nil; + + [self configureWithAsyncDataFetching:NO]; return self; }