ASAvailability.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. //
  2. // ASAvailability.h
  3. // AsyncDisplayKit
  4. //
  5. // Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
  6. // This source code is licensed under the BSD-style license found in the
  7. // LICENSE file in the root directory of this source tree. An additional grant
  8. // of patent rights can be found in the PATENTS file in the same directory.
  9. //
  10. #import <CoreFoundation/CFBase.h>
  11. #pragma once
  12. #ifndef kCFCoreFoundationVersionNumber_iOS_9_0
  13. #define kCFCoreFoundationVersionNumber_iOS_9_0 1240.10
  14. #endif
  15. #ifndef kCFCoreFoundationVersionNumber_iOS_10_0
  16. #define kCFCoreFoundationVersionNumber_iOS_10_0 1348.00
  17. #endif
  18. #define AS_AT_LEAST_IOS9 (kCFCoreFoundationVersionNumber >= kCFCoreFoundationVersionNumber_iOS_9_0)
  19. #define AS_AT_LEAST_IOS10 (kCFCoreFoundationVersionNumber >= kCFCoreFoundationVersionNumber_iOS_10_0)
  20. #define AS_TARGET_OS_OSX (!(TARGET_OS_IOS || TARGET_OS_TV || TARGET_OS_WATCH))
  21. #define AS_TARGET_OS_IOS TARGET_OS_IPHONE
  22. // If Yoga is available, make it available anywhere we use ASAvailability.
  23. // This reduces Yoga-specific code in other files.// If Yoga is available, make it available anywhere we use ASAvailability.
  24. #if __has_include(<Yoga/Yoga.h>)
  25. #define YOGA 1
  26. #endif
  27. #if AS_TARGET_OS_OSX
  28. #define UIEdgeInsets NSEdgeInsets
  29. #define NSStringFromCGSize NSStringFromSize
  30. #define NSStringFromCGPoint NSStringFromPoint
  31. #import <Foundation/Foundation.h>
  32. @interface NSValue (ASAvailability)
  33. + (NSValue *)valueWithCGPoint:(CGPoint)point;
  34. + (NSValue *)valueWithCGSize:(CGSize)size;
  35. - (CGRect)CGRectValue;
  36. - (CGPoint)CGPointValue;
  37. - (CGSize)CGSizeValue;
  38. @end
  39. @implementation NSValue(ASAvailability)
  40. + (NSValue *)valueWithCGPoint:(CGPoint)point
  41. {
  42. return [self valueWithPoint:point];
  43. }
  44. + (NSValue *)valueWithCGSize:(CGSize)size
  45. {
  46. return [self valueWithSize:size];
  47. }
  48. - (CGRect)CGRectValue
  49. {
  50. return self.rectValue;
  51. }
  52. - (CGPoint)CGPointValue
  53. {
  54. return self.pointValue;
  55. }
  56. - (CGSize)CGSizeValue
  57. {
  58. return self.sizeValue;
  59. }
  60. @end
  61. #endif