Skip to content

Instantly share code, notes, and snippets.

@mtsd
Last active March 8, 2017 00:26
Show Gist options
  • Select an option

  • Save mtsd/1398863 to your computer and use it in GitHub Desktop.

Select an option

Save mtsd/1398863 to your computer and use it in GitHub Desktop.
iOSのバージョン判定
#import <Foundation/Foundation.h>
CGFloat iOSVersion();
BOOL isIOSVersionOver(float v);
BOOL isIOSVersionOver_3_2();
BOOL isIOSVersionOver_5_0();
#import "deviceVersionUtility.h"
CGFloat iOSVersion()
{
return [[[UIDevice currentDevice] systemVersion] floatValue];
}
/*
if (isIOSVersionOver(5.0f)) {
...
}
*/
BOOL isIOSVersionOver(float v)
{
float version = iOSVersion();
return version >= v;
}
BOOL isIOSVersionOver_3_2()
{
float version = iOSVersion();
return version >= 3.2f;
}
BOOL isIOSVersionOver_5_0()
{
float version = iOSVersion();
return version >= 5.0f;
}
/**
MACRO
*/
#define SYSTEM_VERSION_LESS_THAN(v) \
( [[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending )
if (SYSTEM_VERSION_LESS_THAN(@"8.0")) {
// iOS7
} else {
// iOS8 -
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment