Skip to content

Instantly share code, notes, and snippets.

@alex-cellcity
Created May 30, 2011 04:55
Show Gist options
  • Select an option

  • Save alex-cellcity/998472 to your computer and use it in GitHub Desktop.

Select an option

Save alex-cellcity/998472 to your computer and use it in GitHub Desktop.
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

Copy link
Copy Markdown

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

@Akhrameev

Copy link
Copy Markdown

Thanks!

@Jusung

Jusung commented Dec 9, 2013

Copy link
Copy Markdown

Simple, Easy and Awesome!

@ramadana

Copy link
Copy Markdown

it really useful ! thanks alex

@lzubiaur

Copy link
Copy Markdown

Simple and useful. Thanks!

@gino24

gino24 commented Nov 16, 2014

Copy link
Copy Markdown

Thanks, so simple and useful !

@TommyQu

TommyQu commented May 12, 2015

Copy link
Copy Markdown

Could you tell me where is Version.m file?

@jsras

jsras commented Oct 27, 2015

Copy link
Copy Markdown

nice one - thanks!

@ramezanpour

Copy link
Copy Markdown

Thanks! Very useful.

@haxpor

haxpor commented Nov 2, 2015

Copy link
Copy Markdown

Thanks man. Works!

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