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