在開發(fā)中,對(duì)于比較版本號(hào)還是必不可少的.比如我們需要判斷當(dāng)前系統(tǒng)的版本號(hào). 來實(shí)現(xiàn)系統(tǒng)的新方法[[UIDevice currentDevice] systemVersion].
之前寫的方式都是使用宏,例如
#define IOS9Later [[[UIDevice currentDevice] systemVersion] floatValue] >= 9
這種方式是可以比較.但是有時(shí)候要對(duì)比當(dāng)前應(yīng)用的版本號(hào)比如@"3.0.1"這種的 上述的方法就不好使了.
由于為了要加一個(gè)強(qiáng)制更新.要判斷這種的版本號(hào),所以改了一個(gè)思路定義了下面的宏;
#define iOSLater(x) [[[UIDevice currentDevice] systemVersion] compare:@#x options:NSNumericSearch] != NSOrderedAscending
這樣子我們可以更方便的判斷了.
if (iOSLater(10)) {
NSLog(@"currentVersion:%@", [[UIDevice currentDevice] systemVersion]);
}