react-native-navigation的迁移库

RNNStore.m 1.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. //
  2. // RNNStore.m
  3. // ReactNativeNavigation
  4. //
  5. // Created by Ran Greenberg on 12/02/2017.
  6. // Copyright © 2017 Wix. All rights reserved.
  7. //
  8. #import "RNNStore.h"
  9. @interface RNNStore ()
  10. @property NSMapTable *containerStore;
  11. @end
  12. @implementation RNNStore
  13. -(instancetype)init {
  14. self = [super init];
  15. self.containerStore = [NSMapTable strongToWeakObjectsMapTable];
  16. self.modalsToDismissArray = [NSMutableArray new];
  17. return self;
  18. }
  19. -(UIViewController *)findContainerForId:(NSString *)containerId {
  20. return [self.containerStore objectForKey:containerId];
  21. }
  22. - (void)setContainer:(UIViewController*)viewController containerId:(NSString*)containerId {
  23. UIViewController *existingVewController = [self findContainerForId:containerId];
  24. if (existingVewController) {
  25. @throw [NSException exceptionWithName:@"MultipleContainerId" reason:[@"Container id already exists " stringByAppendingString:containerId] userInfo:nil];
  26. }
  27. [self.containerStore setObject:viewController forKey:containerId];
  28. }
  29. - (void)removeContainer:(NSString*)containerId {
  30. [self.containerStore removeObjectForKey:containerId];
  31. }
  32. @end