UIPasteboard+FLEX.m 894 B

1234567891011121314151617181920212223242526272829303132
  1. //
  2. // UIPasteboard+FLEX.m
  3. // FLEX
  4. //
  5. // Created by Tanner Bennett on 12/9/19.
  6. // Copyright © 2020 FLEX Team. All rights reserved.
  7. //
  8. #import "UIPasteboard+FLEX.h"
  9. @implementation UIPasteboard (FLEX)
  10. - (void)flex_copy:(id)object {
  11. if (!object) {
  12. return;
  13. }
  14. if ([object isKindOfClass:[NSString class]]) {
  15. UIPasteboard.generalPasteboard.string = object;
  16. } else if([object isKindOfClass:[NSData class]]) {
  17. [UIPasteboard.generalPasteboard setData:object forPasteboardType:@"public.data"];
  18. } else if ([object isKindOfClass:[NSNumber class]]) {
  19. UIPasteboard.generalPasteboard.string = [object stringValue];
  20. } else {
  21. // TODO: make this an alert instead of an exception
  22. [NSException raise:NSInternalInconsistencyException
  23. format:@"Tried to copy unsupported type: %@", [object class]];
  24. }
  25. }
  26. @end