LoginSignup
55
53

More than 5 years have passed since last update.

1行で iOS バージョン判定できる便利マクロ

Posted at

下記のようにマクロを定義しておけば、

#define SYSTEM_VERSION_LESS_THAN(v) ([[[UIDevice currentDevice] systemVersion] \
compare:v options:NSNumericSearch] == NSOrderedAscending)

こんな感じで1行でバージョン判定できて便利です。

if (SYSTEM_VERSION_LESS_THAN(@"6.0"))
{
    // ios 5.x and below
}
else
{
    // ios 6.0 and above
}

普通の実装をマクロで定義しただけですが・・・

55
53
0

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
55
53