4

Well, my questions is really simple i guess.

I use NSFoundationVersionNumber to check the version of my app , and make it both compatible with iOS6 and iOS7 .

if (NSFoundationVersionNumber > NSFoundationVersionNumber_iOS_6_1 ){
//Here goes the code for iOS 7 
}

else if (NSFoundationVersionNumber == NSFoundationVersionNumber_iOS_6_1){
//Here goes the code for iOS 6.1
}

Well,as far as i know, Apple has released 6.1.X versions.So, using the second "else-if" statement, versions 6.1.X are excluded from the list of compatible versions i make?If yes is the answer, then how can i determine ,if the device is running on 6.1.X versions?

Thank you very much :)

rmaddy
  • 314,917
  • 42
  • 532
  • 579
Themis Beris
  • 980
  • 1
  • 11
  • 25

3 Answers3

6

When NSFoundationVersionNumber == NSFoundationVersionNumber_iOS_6_1 is true, then the device has 6.1.X.

When NSFoundationVersionNumber == NSFoundationVersionNumber_iOS_6_0 is true, the device has 6.0.X.

When NSFoundationVersionNumber < NSFoundationVersionNumber_iOS_6_0 is true, the device has 5.1.X and below.

When NSFoundationVersionNumber > NSFoundationVersionNumber_iOS_6_1 is true, the device has 7.0 and above.

DevGansta
  • 5,564
  • 2
  • 16
  • 16
Léo Natan
  • 56,823
  • 9
  • 150
  • 195
  • So you tell me that NSFoundationVersionNumber_iOS_6_1 ,includes iOS 6.1.X versions? Am i right? – Themis Beris Nov 15 '13 at 00:06
  • 2
    Yes, all versions are included. If you want to know precisely which, you will have to drill down `[UIDevice currentDevice].systemVersion`. – Léo Natan Nov 15 '13 at 00:08
  • 2
    That's not 100% true. 6_0 and 6_1 have the same foundation number (993.00 found in NSObjCRuntime.h). So for < NSFoundationVersionNumber_iOS_6_1 the device is 5.1 and below. Small point. – Ben Flynn Nov 19 '13 at 21:43
  • 1
    This answer is no longer accurate, foundation versions for 6_0 and 6_1 are now different (992 & 993 respectively). – Brody Robertson Oct 13 '14 at 21:54
  • And if your device runs OS X 10.9.5, NSFoundationVersionNumber10_9_2 is below the real NSFoundation version and you're out of licl. Still not getting it – Julian F. Weinert Feb 09 '16 at 12:30
  • @Julian Sounds like a bug in OS X SDK. Open a bug report to Apple. – Léo Natan Feb 09 '16 at 12:31
  • @LeoNatan There's just no `#define` for 10.9.5 in the SDK. I solved it by `floor`ing the version, because I'm not interested in the lower version. – Julian F. Weinert Feb 09 '16 at 13:52
  • 1
    @Julian Still, if Apple changed the foundation version, they should have a macro for each version. Still worth a bug report. – Léo Natan Feb 09 '16 at 13:53
2

apple forgot to provide NSFoundationVersionNumber constants for iOS 7, 10.8 and 10.9, but you can get the numbers by NSLogging out your NSFoundationVersionNumer (which gives you the NSFoundationVersionNumber of your current OS)

haag
  • 178
  • 1
  • 7
2

With iOS 8, Apple now provides the NSOperatingSystemVersion struct in NSProcessInfo

You can use it with the isOperatingSystemAtLeastVersion:, or just check the 3 fields to exactly know which system version is running your app.

Imotep
  • 2,006
  • 2
  • 25
  • 38
  • 2
    This is definitely helpful. If you are supporting iOS7 and 8, however, you'll need to use a combination of NSFoundationVersionNumber and respondsToSelector for `isOperatingSystemAtLeastVersion` since that method is "Available in iOS 8.0 and later." – greymouser Feb 23 '15 at 21:48