react-native-navigation的迁移库

Param.m 672B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #import "Param.h"
  2. @interface Param()
  3. @property (nonatomic, retain) id value;
  4. @property (nonatomic) BOOL consumed;
  5. @end
  6. @implementation Param
  7. - (instancetype)initWithValue:(id)value {
  8. self = [super init];
  9. self.value = value;
  10. return self;
  11. }
  12. - (id)get {
  13. if (!self.value) {
  14. @throw [NSException exceptionWithName:@"Param get" reason:@"value does not exists" userInfo:nil];
  15. }
  16. return self.value;
  17. }
  18. - (id)getWithDefaultValue:(id)defaultValue {
  19. if (self.value) {
  20. return self.value;
  21. } else if (defaultValue) {
  22. return defaultValue;
  23. }
  24. return nil;
  25. }
  26. - (void)consume {
  27. self.consumed = true;
  28. }
  29. - (BOOL)hasValue {
  30. return self.value && !self.consumed;
  31. }
  32. @end