-
Notifications
You must be signed in to change notification settings - Fork 0
/
NISDKAvailability.h
217 lines (175 loc) · 5.55 KB
/
NISDKAvailability.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
//
// Copyright 2011 Jeff Verkoeyen
//
// Forked from Three20 June 10, 2011 - Copyright 2009-2011 Facebook
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
/**
* For checking SDK feature availibility.
*
* @ingroup NimbusCore
* @defgroup SDK-Availability SDK Availability
* @{
*
* NIIOS macros are defined in parallel to their __IPHONE_ counterparts as a consistently-defined
* means of checking __IPHONE_OS_VERSION_MAX_ALLOWED.
*
* For example:
*
* @htmlonly
* <pre>
* #if __IPHONE_OS_VERSION_MAX_ALLOWED >= NIIOS_3_2
* // This code will only compile on versions >= iOS 3.2
* #endif
* </pre>
* @endhtmlonly
*/
/**
* Released on July 11, 2008
*/
#define NIIOS_2_0 20000
/**
* Released on September 9, 2008
*/
#define NIIOS_2_1 20100
/**
* Released on November 21, 2008
*/
#define NIIOS_2_2 20200
/**
* Released on June 17, 2009
*/
#define NIIOS_3_0 30000
/**
* Released on September 9, 2009
*/
#define NIIOS_3_1 30100
/**
* Released on April 3, 2010
*/
#define NIIOS_3_2 30200
/**
* Released on June 21, 2010
*/
#define NIIOS_4_0 40000
/**
* Released on September 8, 2010
*/
#define NIIOS_4_1 40100
/**
* Released on November 22, 2010
*/
#define NIIOS_4_2 40200
/**
* Released on March 9, 2011
*/
#define NIIOS_4_3 40300
/**
* Release TBD.
*/
#define NIIOS_5_0 50000
#ifndef kCFCoreFoundationVersionNumber_iPhoneOS_2_0
#define kCFCoreFoundationVersionNumber_iPhoneOS_2_0 478.23
#endif
#ifndef kCFCoreFoundationVersionNumber_iPhoneOS_2_1
#define kCFCoreFoundationVersionNumber_iPhoneOS_2_1 478.26
#endif
#ifndef kCFCoreFoundationVersionNumber_iPhoneOS_2_2
#define kCFCoreFoundationVersionNumber_iPhoneOS_2_2 478.29
#endif
#ifndef kCFCoreFoundationVersionNumber_iPhoneOS_3_0
#define kCFCoreFoundationVersionNumber_iPhoneOS_3_0 478.47
#endif
#ifndef kCFCoreFoundationVersionNumber_iPhoneOS_3_1
#define kCFCoreFoundationVersionNumber_iPhoneOS_3_1 478.52
#endif
#ifndef kCFCoreFoundationVersionNumber_iPhoneOS_3_2
#define kCFCoreFoundationVersionNumber_iPhoneOS_3_2 478.61
#endif
#ifndef kCFCoreFoundationVersionNumber_iOS_4_0
#define kCFCoreFoundationVersionNumber_iOS_4_0 550.32
#endif
/**
* Checks whether the device the app is currently running on is an iPad or not.
*
* @returns YES if the device is an iPad.
*/
BOOL NIIsPad(void);
/**
* Checks whether the device's OS version is at least the given version number.
*
* Useful for runtime checks of the device's version number.
*
* @param versionNumber Any value of kCFCoreFoundationVersionNumber.
*
* @attention Apple recommends using respondsToSelector where possible to check for
* feature support. Use this method as a last resort.
*/
BOOL NIDeviceOSVersionIsAtLeast(double versionNumber);
/**
* Fetch the screen's scale in an SDK-agnostic way. This will work on any pre-iOS 4.0 SDK.
*
* Pre-iOS 4.0: will always return 1.
* iOS 4.0: returns the device's screen scale.
*/
CGFloat NIScreenScale(void);
/**
* Safely fetch the UIPopoverController class if it is available.
*
* The class is cached to avoid repeated lookups.
*
* Uses NSClassFromString to fetch the popover controller class.
*
* This class was first introduced in iOS 3.2 April 3, 2010.
*
* @attention If you wish to maintain pre-iOS 3.2 support then you <b>must</b> use this method
* instead of directly referring to UIPopoverController anywhere within your code.
* Failure to do so will cause your app to crash on startup on pre-iOS 3.2 devices.
*/
Class NIUIPopoverControllerClass(void);
/**
* Safely fetch the UITapGestureRecognizer class if it is available.
*
* The class is cached to avoid repeated lookups.
*
* Uses NSClassFromString to fetch the tap gesture recognizer class.
*
* This class was first introduced in iOS 3.2 April 3, 2010.
*
* @attention If you wish to maintain pre-iOS 3.2 support then you <b>must</b> use this method
* instead of directly referring to UIPopoverController anywhere within your code.
* Failure to do so will cause your app to crash on startup on pre-iOS 3.2 devices.
*/
Class NIUITapGestureRecognizerClass(void);
#pragma mark Building with Old SDKs
// Define classes that were introduced in iOS 3.2.
#if __IPHONE_OS_VERSION_MAX_ALLOWED < NIIOS_3_2
@class UIPopoverController;
@class UITapGestureRecognizer;
#endif
// Define methods that were introduced in iOS 4.0.
#if __IPHONE_OS_VERSION_MAX_ALLOWED < NIIOS_4_0
@interface UIImage (NimbusSDKAvailability)
+ (UIImage *)imageWithCGImage:(CGImageRef)imageRef scale:(CGFloat)scale orientation:(UIImageOrientation)orientation;
- (CGFloat)scale;
@end
@interface UIScreen (NimbusSDKAvailability)
- (CGFloat)scale;
@end
#endif
///////////////////////////////////////////////////////////////////////////////////////////////////
/**@}*/// End of SDK Availability /////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////