FLEXArgumentInputStringView.m 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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 ability 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. // TODO: Support using object address for strings, as in the object arg view.
  30. #pragma mark -
  31. + (BOOL)supportsObjCType:(const char *)type withCurrentValue:(id)value
  32. {
  33. BOOL supported = type && strcmp(type, FLEXEncodeClass(NSString)) == 0;
  34. supported = supported || (value && [value isKindOfClass:[NSString class]]);
  35. return supported;
  36. }
  37. @end