You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
1.1 KiB

  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. #import "FLEXRuntimeUtility.h"
  10. @implementation FLEXArgumentInputStringView
  11. - (instancetype)initWithArgumentTypeEncoding:(const char *)typeEncoding
  12. {
  13. self = [super initWithArgumentTypeEncoding:typeEncoding];
  14. if (self) {
  15. self.targetSize = FLEXArgumentInputViewSizeLarge;
  16. }
  17. return self;
  18. }
  19. - (void)setInputValue:(id)inputValue
  20. {
  21. self.inputTextView.text = inputValue;
  22. }
  23. - (id)inputValue
  24. {
  25. // Interpret empty string as nil. We loose the ablitiy to set empty string as a string value,
  26. // but we accept that tradeoff in exchange for not having to type quotes for every string.
  27. return [self.inputTextView.text length] > 0 ? [self.inputTextView.text copy] : nil;
  28. }
  29. #pragma mark -
  30. + (BOOL)supportsObjCType:(const char *)type withCurrentValue:(id)value
  31. {
  32. BOOL supported = type && strcmp(type, FLEXEncodeClass(NSString)) == 0;
  33. supported = supported || (value && [value isKindOfClass:[NSString class]]);
  34. return supported;
  35. }
  36. @end