FLEXArgumentInputStringView.m 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. //
  2. // FLEXArgumentInputStringView.m
  3. // Flipboard
  4. //
  5. // Created by Ryan Olson on 6/28/14.
  6. // Copyright (c) 2014 Flipboard. All rights reserved.
  7. //
  8. #import "FLEXArgumentInputStringView.h"
  9. @implementation FLEXArgumentInputStringView
  10. - (instancetype)initWithArgumentTypeEncoding:(const char *)typeEncoding
  11. {
  12. self = [super initWithArgumentTypeEncoding:typeEncoding];
  13. if (self) {
  14. self.targetSize = FLEXArgumentInputViewSizeLarge;
  15. }
  16. return self;
  17. }
  18. - (void)setInputValue:(id)inputValue
  19. {
  20. self.inputTextView.text = inputValue;
  21. }
  22. - (id)inputValue
  23. {
  24. // Interpret empty string as nil. We loose the ablitiy to set empty string as a string value,
  25. // but we accept that tradeoff in exchange for not having to type quotes for every string.
  26. return [self.inputTextView.text length] > 0 ? [self.inputTextView.text copy] : nil;
  27. }
  28. #pragma mark -
  29. + (BOOL)supportsObjCType:(const char *)type withCurrentValue:(id)value
  30. {
  31. BOOL supported = strcmp(type, "@\"NSString\"") == 0;
  32. supported = supported || (value && [value isKindOfClass:[NSString class]]);
  33. return supported;
  34. }
  35. @end