diff --git a/iOS/Pod/Classes/DoricContext.h b/iOS/Pod/Classes/DoricContext.h index e51b8b7c..b0bf324f 100644 --- a/iOS/Pod/Classes/DoricContext.h +++ b/iOS/Pod/Classes/DoricContext.h @@ -40,7 +40,7 @@ NS_ASSUME_NONNULL_BEGIN @property(nonatomic, strong) NSString *script;; @property(nonatomic, strong) NSMutableDictionary *initialParams; @property(nonatomic, strong) DoricRootNode *rootNode; -@property(nonatomic, strong) NSMutableSet *headNodes; +@property(nonatomic, strong) NSMutableDictionary *headNodes; - (instancetype)initWithScript:(NSString *)script source:(NSString *)source; diff --git a/iOS/Pod/Classes/DoricContext.m b/iOS/Pod/Classes/DoricContext.m index b9bbbe75..09e946b6 100644 --- a/iOS/Pod/Classes/DoricContext.m +++ b/iOS/Pod/Classes/DoricContext.m @@ -33,7 +33,7 @@ - (instancetype)initWithScript:(NSString *)script source:(NSString *)source { _driver = [DoricDriver instance]; _pluginInstanceMap = [NSMutableDictionary new]; [[DoricContextManager instance] createContext:self script:script source:source]; - _headNodes = [NSMutableSet new]; + _headNodes = [NSMutableDictionary new]; DoricRootNode *rootNode = [[DoricRootNode alloc] initWithContext:self]; _rootNode = rootNode; _script = script; @@ -48,12 +48,7 @@ - (DoricViewNode *)targetViewNode:(NSString *)viewId { if ([self.rootNode.viewId isEqualToString:viewId]) { return self.rootNode; } else { - for (DoricViewNode *node in self.headNodes) { - if ([viewId isEqualToString:node.viewId]) { - return node; - } - } - return nil; + return self.headNodes[viewId]; } } diff --git a/iOS/Pod/Classes/Plugin/DoricPopoverPlugin.m b/iOS/Pod/Classes/Plugin/DoricPopoverPlugin.m index 42b2864f..43125f51 100644 --- a/iOS/Pod/Classes/Plugin/DoricPopoverPlugin.m +++ b/iOS/Pod/Classes/Plugin/DoricPopoverPlugin.m @@ -33,7 +33,7 @@ - (void)show:(NSDictionary *)params withPromise:(DoricPromise *)promise { [it initWithSuperNode:nil]; it.view.layoutConfig = [DoricLayoutConfig new]; [self.fullScreenView addSubview:it.view]; - [self.doricContext.headNodes addObject:it]; + self.doricContext.headNodes[viewId] = it; }]; } [viewNode blend:params[@"props"]]; @@ -55,7 +55,7 @@ - (void)dismiss:(NSDictionary *)params withPromise:(DoricPromise *)promise { } - (void)dismissViewNode:(DoricViewNode *)node { - [self.doricContext.headNodes removeObject:node]; + [self.doricContext.headNodes removeObjectForKey:node.viewId]; [node.view removeFromSuperview]; if (self.doricContext.headNodes.count == 0) { self.fullScreenView.hidden = YES; @@ -63,7 +63,7 @@ - (void)dismissViewNode:(DoricViewNode *)node { } - (void)dismissPopover { - for (DoricViewNode *node in self.doricContext.headNodes) { + for (DoricViewNode *node in self.doricContext.headNodes.allValues) { [self dismissViewNode:node]; } }