How to define preprocessor macro to check iOS version

前端 未结 6 1633
情书的邮戳
情书的邮戳 2021-01-02 20:47

I use it to check iOS version, but it doesn\'t work:

#ifndef kCFCoreFoundationVersionNumber_iPhoneOS_5_0
#define kCFCoreFoundationVersionNumber_iPhoneOS_5_0          


        
6条回答
  •  迷失自我
    2021-01-02 21:34

    Define this method:

    +(BOOL)iOS_5 {
        NSString *osVersion = @"5.0";
        NSString *currOsVersion = [[UIDevice currentDevice] systemVersion];
        return [currOsVersion compare:osVersion options:NSNumericSearch] == NSOrderedAscending;
    }
    

    Then define the macro as that method.

提交回复
热议问题