[ASLayoutSpec.mm] Remove use of dictionary to hold children

Converted the backing store of children to a std::vector. Subclass now have defined indexes instead of string keys to add children.
This commit is contained in:
ricky
2016-06-07 10:07:59 -07:00
parent 6dac29a16f
commit 2675204d50
4 changed files with 41 additions and 56 deletions

View File

@@ -14,7 +14,8 @@
#import "ASBaseDefines.h"
#import "ASLayout.h"
static NSString * const kBackgroundChildKey = @"kBackgroundChildKey";
static NSUInteger const kForegroundChildIndex = 0;
static NSUInteger const kBackgroundChildIndex = 1;
@interface ASBackgroundLayoutSpec ()
@end
@@ -28,7 +29,7 @@ static NSString * const kBackgroundChildKey = @"kBackgroundChildKey";
}
ASDisplayNodeAssertNotNil(child, @"Child cannot be nil");
[self setChild:child];
[self setChild:child forIndex:kForegroundChildIndex];
self.background = background;
return self;
}
@@ -63,12 +64,12 @@ static NSString * const kBackgroundChildKey = @"kBackgroundChildKey";
- (void)setBackground:(id<ASLayoutable>)background
{
[super setChild:background forIdentifier:kBackgroundChildKey];
[super setChild:background forIndex:kBackgroundChildIndex];
}
- (id<ASLayoutable>)background
{
return [super childForIdentifier:kBackgroundChildKey];
return [super childForIndex:kBackgroundChildIndex];
}
@end