react-native-navigation的迁移库

RNNStore.m 947B

1234567891011121314151617181920212223242526272829303132333435363738
  1. #import "RNNStore.h"
  2. @interface RNNStore ()
  3. @end
  4. @implementation RNNStore {
  5. NSMapTable* _containerStore;
  6. }
  7. -(instancetype)init {
  8. self = [super init];
  9. _containerStore = [NSMapTable strongToWeakObjectsMapTable];
  10. self.modalsToDismissArray = [NSMutableArray new];
  11. return self;
  12. }
  13. -(UIViewController *)findContainerForId:(NSString *)containerId {
  14. return [_containerStore objectForKey:containerId];
  15. }
  16. - (void)setContainer:(UIViewController*)viewController containerId:(NSString*)containerId {
  17. UIViewController *existingVewController = [self findContainerForId:containerId];
  18. if (existingVewController) {
  19. @throw [NSException exceptionWithName:@"MultipleContainerId" reason:[@"Container id already exists " stringByAppendingString:containerId] userInfo:nil];
  20. }
  21. [_containerStore setObject:viewController forKey:containerId];
  22. }
  23. - (void)removeContainer:(NSString*)containerId {
  24. [_containerStore removeObjectForKey:containerId];
  25. }
  26. @end