LoginSignup
49
48

More than 5 years have passed since last update.

objective-c で iOS 7 かどうか判定する (又はマクロでバージョン判定する)

Last updated at Posted at 2013-09-24

Utilクラスとかを定義して以下のメソッド作っておくと便利。
マイナーバージョンは見てないので、7.1になっても大丈夫(なはず)。

+ (BOOL)isIOS7
{
    NSArray  *aOsVersions = [[[UIDevice currentDevice]systemVersion] componentsSeparatedByString:@"."];
    NSInteger iOsVersionMajor  = [[aOsVersions objectAtIndex:0] intValue];
    if (iOsVersionMajor == 7)
    {
        return YES;
    }

    return NO;
}

追記:

マクロで定義する方法もあるそうです。 @skonb さん、ありがとうございます!

#define SYSTEM_VERSION_EQUAL_TO(v)  ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedSame)
49
48
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
49
48