RCTTextSelection.m 768 B

123456789101112131415161718192021222324252627282930313233343536
  1. /*
  2. * Copyright (c) Facebook, Inc. and its affiliates.
  3. *
  4. * This source code is licensed under the MIT license found in the
  5. * LICENSE file in the root directory of this source tree.
  6. */
  7. #import <React/RCTTextSelection.h>
  8. @implementation RCTTextSelection
  9. - (instancetype)initWithStart:(NSInteger)start end:(NSInteger)end
  10. {
  11. if (self = [super init]) {
  12. _start = start;
  13. _end = end;
  14. }
  15. return self;
  16. }
  17. @end
  18. @implementation RCTConvert (RCTTextSelection)
  19. + (RCTTextSelection *)RCTTextSelection:(id)json
  20. {
  21. if ([json isKindOfClass:[NSDictionary class]]) {
  22. NSInteger start = [self NSInteger:json[@"start"]];
  23. NSInteger end = [self NSInteger:json[@"end"]];
  24. return [[RCTTextSelection alloc] initWithStart:start end:end];
  25. }
  26. return nil;
  27. }
  28. @end