react-native-navigation的迁移库

RNNStore.m 1.0KB

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 NSMutableDictionary *containerStore;
  11. @end
  12. @implementation RNNStore
  13. -(instancetype)init {
  14. self = [super init];
  15. self.containerStore = [NSMutableDictionary new];
  16. return self;
  17. }
  18. -(UIViewController *)findContainerForId:(NSString *)containerId {
  19. return [self.containerStore valueForKey:containerId];
  20. }
  21. - (void)setContainer:(UIViewController*)viewController containerId:(NSString*)containerId {
  22. UIViewController *existingVewController = [self findContainerForId:containerId];
  23. if (existingVewController) {
  24. @throw [NSException exceptionWithName:@"MultipleContainerId" reason:[@"Container id already exists " stringByAppendingString:containerId] userInfo:nil];
  25. }
  26. [self.containerStore setObject:viewController forKey:containerId];
  27. }
  28. - (void)removeContainer:(NSString*)containerId {
  29. [self.containerStore removeObjectForKey:containerId];
  30. }
  31. @end