Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Runtime iOS Version Checking
/*
* System Versioning Preprocessor Macros
*/
#define SYSTEM_VERSION_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedSame)
#define SYSTEM_VERSION_GREATER_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending)
#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedDescending)
/*
* Usage
*/
if (SYSTEM_VERSION_LESS_THAN(@"4.0")) {
...
}
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"3.1.1")) {
...
}
@willmoore

This comment has been minimized.

Copy link

@willmoore willmoore commented Mar 22, 2013

Perfect, simple way to work with iOS versions ...

@Akhrameev

This comment has been minimized.

Copy link

@Akhrameev Akhrameev commented Oct 26, 2013

Thanks!

@Jusung

This comment has been minimized.

Copy link

@Jusung Jusung commented Dec 9, 2013

Simple, Easy and Awesome!

@ramadana

This comment has been minimized.

Copy link

@ramadana ramadana commented Jun 12, 2014

it really useful ! thanks alex

@lzubiaur

This comment has been minimized.

Copy link

@lzubiaur lzubiaur commented Oct 14, 2014

Simple and useful. Thanks!

@gino24

This comment has been minimized.

Copy link

@gino24 gino24 commented Nov 16, 2014

Thanks, so simple and useful !

@TommyQu

This comment has been minimized.

Copy link

@TommyQu TommyQu commented May 12, 2015

Could you tell me where is Version.m file?

@jsras

This comment has been minimized.

Copy link

@jsras jsras commented Oct 27, 2015

nice one - thanks!

@ramezanpour

This comment has been minimized.

Copy link

@ramezanpour ramezanpour commented Oct 29, 2015

Thanks! Very useful.

@haxpor

This comment has been minimized.

Copy link

@haxpor haxpor commented Nov 2, 2015

Thanks man. Works!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment