Fix the Initialization Hierarchy (#3207)

* Fix the initializers setup

* Update Swift example

* Remove incorrect comment

* Add one to ASTableNode
This commit is contained in:
Adlai Holler
2017-03-28 11:48:20 -07:00
committed by GitHub
parent 27c94069ae
commit fcbbea51a6
10 changed files with 84 additions and 88 deletions

View File

@@ -123,14 +123,6 @@
}
}
- (instancetype)init
{
ASDISPLAYNODE_NOT_DESIGNATED_INITIALIZER();
UICollectionViewLayout *nilLayout = nil;
self = [self initWithCollectionViewLayout:nilLayout]; // Will throw an exception for lacking a UICV Layout.
return nil;
}
- (instancetype)initWithCollectionViewLayout:(UICollectionViewLayout *)layout
{
return [self initWithFrame:CGRectZero collectionViewLayout:layout layoutFacilitator:nil];
@@ -143,17 +135,14 @@
- (instancetype)initWithFrame:(CGRect)frame collectionViewLayout:(UICollectionViewLayout *)layout layoutFacilitator:(id<ASCollectionViewLayoutFacilitatorProtocol>)layoutFacilitator
{
__weak __typeof__(self) weakSelf = self;
ASDisplayNodeViewBlock collectionViewBlock = ^UIView *{
// Variable will be unused if event logging is off.
__unused __typeof__(self) strongSelf = weakSelf;
return [[[strongSelf collectionViewClass] alloc] _initWithFrame:frame collectionViewLayout:layout layoutFacilitator:layoutFacilitator eventLog:ASDisplayNodeGetEventLog(strongSelf)];
};
if (self = [super initWithViewBlock:collectionViewBlock didLoadBlock:nil]) {
return self;
if (self = [super init]) {
__weak __typeof__(self) weakSelf = self;
[self setViewBlock:^{
__typeof__(self) strongSelf = weakSelf;
return [[[strongSelf collectionViewClass] alloc] _initWithFrame:frame collectionViewLayout:layout layoutFacilitator:layoutFacilitator eventLog:ASDisplayNodeGetEventLog(strongSelf)];
}];
}
return nil;
return self;
}
#pragma mark ASDisplayNode