Advertisement
Guest User

Untitled

a guest
May 26th, 2015
263
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.48 KB | None | 0 0
  1. //
  2. // MJGImageLoader.h
  3. // MJGFoundation
  4. //
  5. // Created by Matt Galloway on 18/01/2012.
  6. // Copyright 2012 Matt Galloway. All rights reserved.
  7. //
  8.  
  9. /**
  10. * Example usage:
  11. * If you want to see if you're using methods that are only defined in iOS 4.0 and lower
  12. * then you would use the following. Replace the __IPHONE_4_0 with whatever other macro
  13. * you require. See Availability.h for iOS versions these relate to.
  14. *
  15. * YourProjectPrefixHeader.pch:
  16. * // #define __IPHONE_OS_VERSION_SOFT_MAX_REQUIRED __IPHONE_4_0
  17. * #import "MJGAvailability.h"
  18. *
  19. * // The rest of your prefix header as normal
  20. * #import <UIKit/UIKit.h>
  21. *
  22. * For OSX, you also get the warnings:
  23. *
  24. * YourOSXPrefixHeader.pch
  25. * #define __MAC_OS_X_VERSION_SOFT_MAX_REQUIRED __MAC_10_7
  26. * #import "MJGAvailability.h"
  27. *
  28. * If you want to suppress a single warning (i.e. because you know that what you're doing is
  29. * actually OK) then you can do something like this:
  30. *
  31. * UINavigationBar *navBar = self.navigationController.navigationBar;
  32. * if ([navBar respondsToSelector:@selector(setBackgroundImage:forBarMetrics:)]) {
  33. * #pragma clang diagnostic push
  34. * #pragma clang diagnostic ignored "-Wdeprecated-declarations"
  35. * [navBar setBackgroundImage:[UIImage imageNamed:@"navbar_bg.png"] forBarMetrics:UIBarMetricsDefault];
  36. * #pragma clang diagnostic pop
  37. * }
  38. *
  39. * Or you can use the handy macros defined in this file also, like this:
  40. *
  41. * UINavigationBar *navBar = self.navigationController.navigationBar;
  42. * if ([navBar respondsToSelector:@selector(setBackgroundImage:forBarMetrics:)]) {
  43. * MJG_START_IGNORE_TOO_NEW
  44. * [navBar setBackgroundImage:[UIImage imageNamed:@"navbar_bg.png"] forBarMetrics:UIBarMetricsDefault];
  45. * MJG_END_IGNORE_TOO_NEW
  46. * }
  47. *
  48. */
  49.  
  50. #import <Availability.h>
  51.  
  52. #define MJG_START_IGNORE_TOO_NEW _Pragma("clang diagnostic push") _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"")
  53. #define MJG_END_IGNORE_TOO_NEW _Pragma("clang diagnostic pop")
  54.  
  55. #define __AVAILABILITY_TOO_NEW __attribute__((deprecated("API IS TOO NEW!"))) __attribute__((weak_import))
  56.  
  57. #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
  58.  
  59. #ifndef __IPHONE_OS_VERSION_SOFT_MAX_REQUIRED
  60. #define __IPHONE_OS_VERSION_SOFT_MAX_REQUIRED __IPHONE_OS_VERSION_MIN_REQUIRED
  61. #endif
  62.  
  63. #if __IPHONE_OS_VERSION_SOFT_MAX_REQUIRED < __IPHONE_OS_VERSION_MIN_REQUIRED
  64. #error You cannot ask for a soft max version which is less than the deployment target
  65. #endif
  66.  
  67. #if __IPHONE_OS_VERSION_SOFT_MAX_REQUIRED < __IPHONE_2_0
  68. #undef __AVAILABILITY_INTERNAL__IPHONE_2_0
  69. #define __AVAILABILITY_INTERNAL__IPHONE_2_0 __AVAILABILITY_TOO_NEW
  70. #endif
  71.  
  72. #if __IPHONE_OS_VERSION_SOFT_MAX_REQUIRED < __IPHONE_2_1
  73. #undef __AVAILABILITY_INTERNAL__IPHONE_2_1
  74. #define __AVAILABILITY_INTERNAL__IPHONE_2_1 __AVAILABILITY_TOO_NEW
  75. #endif
  76.  
  77. #if __IPHONE_OS_VERSION_SOFT_MAX_REQUIRED < __IPHONE_2_2
  78. #undef __AVAILABILITY_INTERNAL__IPHONE_2_2
  79. #define __AVAILABILITY_INTERNAL__IPHONE_2_2 __AVAILABILITY_TOO_NEW
  80. #endif
  81.  
  82. #if __IPHONE_OS_VERSION_SOFT_MAX_REQUIRED < __IPHONE_3_0
  83. #undef __AVAILABILITY_INTERNAL__IPHONE_3_0
  84. #define __AVAILABILITY_INTERNAL__IPHONE_3_0 __AVAILABILITY_TOO_NEW
  85. #endif
  86.  
  87. #if __IPHONE_OS_VERSION_SOFT_MAX_REQUIRED < __IPHONE_3_1
  88. #undef __AVAILABILITY_INTERNAL__IPHONE_3_1
  89. #define __AVAILABILITY_INTERNAL__IPHONE_3_1 __AVAILABILITY_TOO_NEW
  90. #endif
  91.  
  92. #if __IPHONE_OS_VERSION_SOFT_MAX_REQUIRED < __IPHONE_3_2
  93. #undef __AVAILABILITY_INTERNAL__IPHONE_3_2
  94. #define __AVAILABILITY_INTERNAL__IPHONE_3_2 __AVAILABILITY_TOO_NEW
  95. #endif
  96.  
  97. #if __IPHONE_OS_VERSION_SOFT_MAX_REQUIRED < __IPHONE_4_0
  98. #undef __AVAILABILITY_INTERNAL__IPHONE_4_0
  99. #define __AVAILABILITY_INTERNAL__IPHONE_4_0 __AVAILABILITY_TOO_NEW
  100. #endif
  101.  
  102. #if __IPHONE_OS_VERSION_SOFT_MAX_REQUIRED < __IPHONE_4_1
  103. #undef __AVAILABILITY_INTERNAL__IPHONE_4_1
  104. #define __AVAILABILITY_INTERNAL__IPHONE_4_1 __AVAILABILITY_TOO_NEW
  105. #endif
  106.  
  107. #if __IPHONE_OS_VERSION_SOFT_MAX_REQUIRED < __IPHONE_4_2
  108. #undef __AVAILABILITY_INTERNAL__IPHONE_4_2
  109. #define __AVAILABILITY_INTERNAL__IPHONE_4_2 __AVAILABILITY_TOO_NEW
  110. #endif
  111.  
  112. #if __IPHONE_OS_VERSION_SOFT_MAX_REQUIRED < __IPHONE_4_3
  113. #undef __AVAILABILITY_INTERNAL__IPHONE_4_3
  114. #define __AVAILABILITY_INTERNAL__IPHONE_4_3 __AVAILABILITY_TOO_NEW
  115. #endif
  116.  
  117. #if __IPHONE_OS_VERSION_SOFT_MAX_REQUIRED < __IPHONE_5_0
  118. #undef __AVAILABILITY_INTERNAL__IPHONE_5_0
  119. #define __AVAILABILITY_INTERNAL__IPHONE_5_0 __AVAILABILITY_TOO_NEW
  120. #endif
  121.  
  122. #if __IPHONE_OS_VERSION_SOFT_MAX_REQUIRED < __IPHONE_5_1
  123. #undef __AVAILABILITY_INTERNAL__IPHONE_5_1
  124. #define __AVAILABILITY_INTERNAL__IPHONE_5_1 __AVAILABILITY_TOO_NEW
  125. #endif
  126.  
  127. #if __IPHONE_OS_VERSION_SOFT_MAX_REQUIRED < __IPHONE_6_0
  128. #undef __AVAILABILITY_INTERNAL__IPHONE_6_0
  129. #define __AVAILABILITY_INTERNAL__IPHONE_6_0 __AVAILABILITY_TOO_NEW
  130. #endif
  131.  
  132. #if __IPHONE_OS_VERSION_SOFT_MAX_REQUIRED < __IPHONE_6_1
  133. #undef __AVAILABILITY_INTERNAL__IPHONE_6_1
  134. #define __AVAILABILITY_INTERNAL__IPHONE_6_1 __AVAILABILITY_TOO_NEW
  135. #endif
  136.  
  137. #if __IPHONE_OS_VERSION_SOFT_MAX_REQUIRED < __IPHONE_7_0
  138. #undef __AVAILABILITY_INTERNAL__IPHONE_7_0
  139. #define __AVAILABILITY_INTERNAL__IPHONE_7_0 __AVAILABILITY_TOO_NEW
  140. #endif
  141.  
  142. #if __IPHONE_OS_VERSION_SOFT_MAX_REQUIRED < __IPHONE_7_1
  143. #undef __AVAILABILITY_INTERNAL__IPHONE_7_1
  144. #define __AVAILABILITY_INTERNAL__IPHONE_7_1 __AVAILABILITY_TOO_NEW
  145. #endif
  146.  
  147. #if __IPHONE_OS_VERSION_SOFT_MAX_REQUIRED < __IPHONE_8_0
  148. #undef __AVAILABILITY_INTERNAL__IPHONE_8_0
  149. #define __AVAILABILITY_INTERNAL__IPHONE_8_0 __AVAILABILITY_TOO_NEW
  150. #endif
  151.  
  152. #if __IPHONE_OS_VERSION_SOFT_MAX_REQUIRED < __IPHONE_8_1
  153. #undef __AVAILABILITY_INTERNAL__IPHONE_8_1
  154. #define __AVAILABILITY_INTERNAL__IPHONE_8_1 __AVAILABILITY_TOO_NEW
  155. #endif
  156.  
  157. #if __IPHONE_OS_VERSION_SOFT_MAX_REQUIRED < __IPHONE_8_2
  158. #undef __AVAILABILITY_INTERNAL__IPHONE_8_2
  159. #define __AVAILABILITY_INTERNAL__IPHONE_8_2 __AVAILABILITY_TOO_NEW
  160. #endif
  161.  
  162. #if __IPHONE_OS_VERSION_SOFT_MAX_REQUIRED < __IPHONE_8_3
  163. #undef __AVAILABILITY_INTERNAL__IPHONE_8_3
  164. #define __AVAILABILITY_INTERNAL__IPHONE_8_3 __AVAILABILITY_TOO_NEW
  165. #endif
  166.  
  167. #endif // end of #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
  168.  
  169. #if defined(__MAC_OS_X_VERSION_MIN_REQUIRED)
  170.  
  171. #ifndef __MAC_OS_X_VERSION_SOFT_MAX_REQUIRED
  172. #define __MAC_OS_X_VERSION_SOFT_MAX_REQUIRED __MAC_OS_X_VERSION_MIN_REQUIRED
  173. #endif
  174.  
  175. #if __MAC_OS_X_VERSION_SOFT_MAX_REQUIRED < __MAC_OS_X_VERSION_MIN_REQUIRED
  176. #error You cannot ask for a soft max version which is less than the deployment target
  177. #endif
  178.  
  179. #if __MAC_OS_X_VERSION_SOFT_MAX_REQUIRED < __MAC_10_0
  180. #undef __AVAILABILITY_INTERNAL__MAC_10_0
  181. #define __AVAILABILITY_INTERNAL__MAC_10_0 __AVAILABILITY_TOO_NEW
  182. #endif
  183.  
  184. #if __MAC_OS_X_VERSION_SOFT_MAX_REQUIRED < __MAC_10_1
  185. #undef __AVAILABILITY_INTERNAL__MAC_10_1
  186. #define __AVAILABILITY_INTERNAL__MAC_10_1 __AVAILABILITY_TOO_NEW
  187. #endif
  188.  
  189. #if __MAC_OS_X_VERSION_SOFT_MAX_REQUIRED < __MAC_10_2
  190. #undef __AVAILABILITY_INTERNAL__MAC_10_2
  191. #define __AVAILABILITY_INTERNAL__MAC_10_2 __AVAILABILITY_TOO_NEW
  192. #endif
  193.  
  194. #if __MAC_OS_X_VERSION_SOFT_MAX_REQUIRED < __MAC_10_3
  195. #undef __AVAILABILITY_INTERNAL__MAC_10_3
  196. #define __AVAILABILITY_INTERNAL__MAC_10_3 __AVAILABILITY_TOO_NEW
  197. #endif
  198.  
  199. #if __MAC_OS_X_VERSION_SOFT_MAX_REQUIRED < __MAC_10_4
  200. #undef __AVAILABILITY_INTERNAL__MAC_10_4
  201. #define __AVAILABILITY_INTERNAL__MAC_10_4 __AVAILABILITY_TOO_NEW
  202. #endif
  203.  
  204. #if __MAC_OS_X_VERSION_SOFT_MAX_REQUIRED < __MAC_10_5
  205. #undef __AVAILABILITY_INTERNAL__MAC_10_5
  206. #define __AVAILABILITY_INTERNAL__MAC_10_5 __AVAILABILITY_TOO_NEW
  207. #endif
  208.  
  209. #if __MAC_OS_X_VERSION_SOFT_MAX_REQUIRED < __MAC_10_6
  210. #undef __AVAILABILITY_INTERNAL__MAC_10_6
  211. #define __AVAILABILITY_INTERNAL__MAC_10_6 __AVAILABILITY_TOO_NEW
  212. #endif
  213.  
  214. #if __MAC_OS_X_VERSION_SOFT_MAX_REQUIRED < __MAC_10_7
  215. #undef __AVAILABILITY_INTERNAL__MAC_10_7
  216. #define __AVAILABILITY_INTERNAL__MAC_10_7 __AVAILABILITY_TOO_NEW
  217. #endif
  218.  
  219. #if __MAC_OS_X_VERSION_SOFT_MAX_REQUIRED < __MAC_10_8
  220. #undef __AVAILABILITY_INTERNAL__MAC_10_8
  221. #define __AVAILABILITY_INTERNAL__MAC_10_8 __AVAILABILITY_TOO_NEW
  222. #endif
  223.  
  224. #if __MAC_OS_X_VERSION_SOFT_MAX_REQUIRED < __MAC_10_9
  225. #undef __AVAILABILITY_INTERNAL__MAC_10_9
  226. #define __AVAILABILITY_INTERNAL__MAC_10_9 __AVAILABILITY_TOO_NEW
  227. #endif
  228.  
  229. #endif // end of #if defined(__MAC_OS_X_VERSION_MIN_REQUIRED)
  230.  
  231. #if (defined(__IPHONE_7_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_7_0) || (defined(__MAC_10_9) && __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_10_9)
  232. #include <CoreFoundation/CFAvailability.h>
  233. #undef CF_AVAILABLE
  234. #define CF_AVAILABLE(_mac, _ios) __OSX_AVAILABLE_STARTING(__MAC_##_mac, __IPHONE_##_ios)
  235. #undef CF_AVAILABLE_MAC
  236. #define CF_AVAILABLE_MAC(_mac) __OSX_AVAILABLE_STARTING(__MAC_##_mac, __IPHONE_NA)
  237. #undef CF_AVAILABLE_IOS
  238. #define CF_AVAILABLE_IOS(_ios) __OSX_AVAILABLE_STARTING(__MAC_NA, __IPHONE_##_ios)
  239. #endif // if iOS SDK >= 7.0 || OSX SDK >= 10.9
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement