react-native-navigation的迁移库

RNNStore.m 985B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. if (!containerId) {
  23. return;
  24. }
  25. UIViewController *existingVewController = [self findContainerForId:containerId];
  26. if (existingVewController) {
  27. @throw [NSException exceptionWithName:@"MultipleContainerId" reason:[@"Container id already exists " stringByAppendingString:containerId] userInfo:nil]; }
  28. [self.containerStore setObject:viewController forKey:containerId];
  29. }
  30. @end