react-native-navigation的迁移库

RNNStore.m 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #import "RNNStore.h"
  2. @interface RNNStore ()
  3. @end
  4. @implementation RNNStore {
  5. NSMapTable* _containerStore;
  6. NSMutableArray* _pendingModalIdsToDismiss;
  7. BOOL _isReadyToReceiveCommands;
  8. }
  9. -(instancetype)init {
  10. self = [super init];
  11. _isReadyToReceiveCommands = false;
  12. _containerStore = [NSMapTable strongToWeakObjectsMapTable];
  13. _pendingModalIdsToDismiss = [NSMutableArray new];
  14. return self;
  15. }
  16. -(UIViewController *)findContainerForId:(NSString *)containerId {
  17. return [_containerStore objectForKey:containerId];
  18. }
  19. - (void)setContainer:(UIViewController*)viewController containerId:(NSString*)containerId {
  20. UIViewController *existingVewController = [self findContainerForId:containerId];
  21. if (existingVewController) {
  22. @throw [NSException exceptionWithName:@"MultipleContainerId" reason:[@"Container id already exists " stringByAppendingString:containerId] userInfo:nil];
  23. }
  24. [_containerStore setObject:viewController forKey:containerId];
  25. }
  26. - (void)removeContainer:(NSString*)containerId {
  27. [_containerStore removeObjectForKey:containerId];
  28. }
  29. -(void)setReadyToReceiveCommands:(BOOL)isReady {
  30. _isReadyToReceiveCommands = isReady;
  31. }
  32. -(BOOL)isReadyToReceiveCommands {
  33. return _isReadyToReceiveCommands;
  34. }
  35. -(NSMutableArray *)pendingModalIdsToDismiss {
  36. return _pendingModalIdsToDismiss;
  37. }
  38. -(void)clean {
  39. _isReadyToReceiveCommands = false;
  40. [_pendingModalIdsToDismiss removeAllObjects];
  41. [_containerStore removeAllObjects];
  42. }
  43. @end