LOTLayerGroup.m
1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
//
// LOTLayerGroup.m
// Pods
//
// Created by Brandon Withrow on 2/16/17.
//
//
#import "LOTLayerGroup.h"
#import "LOTLayer.h"
#import "LOTAssetGroup.h"
@implementation LOTLayerGroup {
NSDictionary *_modelMap;
NSDictionary *_referenceIDMap;
}
- (instancetype)initWithLayerJSON:(NSArray *)layersJSON
withAssetGroup:(LOTAssetGroup * _Nullable)assetGroup
withFramerate:(NSNumber *)framerate {
self = [super init];
if (self) {
[self _mapFromJSON:layersJSON withAssetGroup:assetGroup withFramerate:framerate];
}
return self;
}
- (void)_mapFromJSON:(NSArray *)layersJSON
withAssetGroup:(LOTAssetGroup * _Nullable)assetGroup
withFramerate:(NSNumber *)framerate {
NSMutableArray *layers = [NSMutableArray array];
NSMutableDictionary *modelMap = [NSMutableDictionary dictionary];
NSMutableDictionary *referenceMap = [NSMutableDictionary dictionary];
for (NSDictionary *layerJSON in layersJSON) {
LOTLayer *layer = [[LOTLayer alloc] initWithJSON:layerJSON
withAssetGroup:assetGroup
withFramerate:framerate];
[layers addObject:layer];
modelMap[layer.layerID] = layer;
if (layer.referenceID) {
referenceMap[layer.referenceID] = layer;
}
}
_referenceIDMap = referenceMap;
_modelMap = modelMap;
_layers = layers;
}
- (LOTLayer *)layerModelForID:(NSNumber *)layerID {
return _modelMap[layerID];
}
- (LOTLayer *)layerForReferenceID:(NSString *)referenceID {
return _referenceIDMap[referenceID];
}
@end