react-native-navigation的迁移库

RNNStore.m 976B

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