How to check iOS version?

后端 未结 30 2416
一生所求
一生所求 2020-11-21 06:37

I want to check if the iOS version of the device is greater than 3.1.3 I tried things like:

[[UIDevice currentDevice].systemVersion         


        
30条回答
  •  情歌与酒
    2020-11-21 07:16

    I know this is an old question, but someone should have mentioned the compile-time macros in Availability.h. All of the other methods here are runtime solutions, and will not work in a header file, class category, or ivar definition.

    For these situations, use

    #if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_6_0
      // iOS 6+ code here
    #else
      // Pre iOS 6 code here
    #endif
    

    h/t this answer

提交回复
热议问题