Currently development only want the minimum version to support IOS8, iOS8 before, and then now IOS9 and iOS10 out, some new APIs, there are some deprecated APIs, in order to be compatible, sometimes the code needs to write to determine the different iOS version, Or allow only the specified iOS version to be compiled or executed.
Need to use the following methods, only for OC (Swift's writing is not clear, and so on when needed to supplement):
Example:
ios8.0 later replaces willrotatetointerfaceorientation:duration with this method: This method # if __iphone_os_version_max_allowed >= 80000// The view controller rotates to a size-(void) Viewwilltransitiontosize: (cgsize) size withtransitioncoordinator: (ID < uiviewcontrollertransitioncoordinator>) coordinator{[Super Viewwilltransitiontosize:size Withtransitioncoordinator:coordinator]; if (Size.Height > Size.width) {NSLog (@ "-------The current device orientation is vertical-------"); } else {NSLog (@ "-------The current device orientation is a horizontal screen-------"); }} #endif
__iphone_os_version_min_required: Minimum iOS version required
__iphone_os_version_max_allowed: Allow the largest iOS version
#define __MAC_10_0
#define __MAC_10_1 1010
#define __MAC_10_2 1020
#define __MAC_10_3 1030
#define __MAC_10_4 1040
#define __MAC_10_5 1050
#define __MAC_10_6 1060
#define __MAC_10_7 1070
#define __MAC_10_8
#define __MAC_10_9 1090
#define __MAC_10_10 101000
#define __MAC_10_10_2 101002
#define __MAC_10_10_3 101003
#define __MAC_10_11 101100
#define __mac_10_11_2 101102
#define __MAC_10_11_3 101103
#define __MAC_10_11_4 101104
#define __mac_10_12 101200
/* __mac_na is isn't defined to a value but was uses as a token by macros to indicate that the API is unavailable */
#define __IPHONE_2_0 20000
#define __iphone_2_1 20100
#define __iphone_2_2 20200
#define __IPHONE_3_0 30000
#define __iphone_3_1 30100
#define __iphone_3_2 30200
#define __IPHONE_4_0 40000
#define __iphone_4_1 40100
#define __iphone_4_2 40200
#define __iphone_4_3 40300
#define __IPHONE_5_0 50000
#define __iphone_5_1 50100
#define __IPHONE_6_0 60000
#define __iphone_6_1 60100
#define __IPHONE_7_0 70000
#define __IPHONE_7_1 70100
#define __IPHONE_8_0 80000
#define __IPHONE_8_1 80100
#define __IPHONE_8_2 80200
#define __IPHONE_8_3 80300
#define __IPHONE_8_4 80400
#define __IPHONE_9_0 90000
#define __IPHONE_9_1 90100
#define __iphone_9_2 90200
#define __IPHONE_9_3 90300
#define __IPHONE_10_0 100000
/* __iphone_na is isn't defined to a value but was uses as a token by macros to indicate that the API is unavailable */
#define __TVOS_9_0 90000
#define __TVOS_9_1 90100
#define __tvos_9_2 90200
#define __TVOS_10_0 100000
#define __WATCHOS_1_0 10000
#define __WATCHOS_2_0 20000
#define __WATCHOS_3_0 30000
You can press and hold the command key in Xcode and click to view more official defined macros.
Different iOS versions do code to match __iphone_os_version_max_allowed and __iphone_8_0 terminology