SDWebImageCompat.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /*
  2. * This file is part of the SDWebImage package.
  3. * (c) Olivier Poitrey <rs@dailymotion.com>
  4. * (c) Jamie Pinkham
  5. *
  6. * For the full copyright and license information, please view the LICENSE
  7. * file that was distributed with this source code.
  8. */
  9. #import <TargetConditionals.h>
  10. #ifdef __OBJC_GC__
  11. #error SDWebImage does not support Objective-C Garbage Collection
  12. #endif
  13. // Seems like TARGET_OS_MAC is always defined (on all platforms).
  14. // To determine if we are running on macOS, use TARGET_OS_OSX in Xcode 8
  15. #if TARGET_OS_OSX
  16. #define SD_MAC 1
  17. #else
  18. #define SD_MAC 0
  19. #endif
  20. // iOS and tvOS are very similar, UIKit exists on both platforms
  21. // Note: watchOS also has UIKit, but it's very limited
  22. #if TARGET_OS_IOS || TARGET_OS_TV
  23. #define SD_UIKIT 1
  24. #else
  25. #define SD_UIKIT 0
  26. #endif
  27. #if TARGET_OS_IOS
  28. #define SD_IOS 1
  29. #else
  30. #define SD_IOS 0
  31. #endif
  32. #if TARGET_OS_TV
  33. #define SD_TV 1
  34. #else
  35. #define SD_TV 0
  36. #endif
  37. #if TARGET_OS_WATCH
  38. #define SD_WATCH 1
  39. #else
  40. #define SD_WATCH 0
  41. #endif
  42. #if SD_MAC
  43. #import <AppKit/AppKit.h>
  44. #ifndef UIImage
  45. #define UIImage NSImage
  46. #endif
  47. #ifndef UIImageView
  48. #define UIImageView NSImageView
  49. #endif
  50. #ifndef UIView
  51. #define UIView NSView
  52. #endif
  53. #ifndef UIColor
  54. #define UIColor NSColor
  55. #endif
  56. #else
  57. #if SD_UIKIT
  58. #import <UIKit/UIKit.h>
  59. #endif
  60. #if SD_WATCH
  61. #import <WatchKit/WatchKit.h>
  62. #ifndef UIView
  63. #define UIView WKInterfaceObject
  64. #endif
  65. #ifndef UIImageView
  66. #define UIImageView WKInterfaceImage
  67. #endif
  68. #endif
  69. #endif
  70. #ifndef NS_ENUM
  71. #define NS_ENUM(_type, _name) enum _name : _type _name; enum _name : _type
  72. #endif
  73. #ifndef NS_OPTIONS
  74. #define NS_OPTIONS(_type, _name) enum _name : _type _name; enum _name : _type
  75. #endif
  76. #ifndef dispatch_main_async_safe
  77. #define dispatch_main_async_safe(block)\
  78. if (dispatch_queue_get_label(DISPATCH_CURRENT_QUEUE_LABEL) == dispatch_queue_get_label(dispatch_get_main_queue())) {\
  79. block();\
  80. } else {\
  81. dispatch_async(dispatch_get_main_queue(), block);\
  82. }
  83. #endif