On Jul 10, 2015, at 7:31 PM, Ben Kennedy <b...@zygoat.ca> wrote:
> 
> On 10 Jul 2015, at 12:01 pm, Charles Srstka <cocoa...@charlessoft.com> wrote:
> 
>> What this means is that if you try to use an El Capitan-only feature and put 
>> it in a block that starts with a check on floor(NSFoundationVersionNumber) 
>> or floor(NSAppKitVersionNumber) to make sure it’s larger than the value for 
>> 10.10.0, your code in that block will get called on all versions of 10.10.x 
>> greater than 10.10.1.
> 
> NSObjCRuntime.h only declares a reference version constant for up to 10.9.2 
> (NSFoundationVersionNumber10_9_2).  I presume your methodology relies on an 
> empirical determination of what later versions of Foundation appear to expose?

You can verify this yourself by booting into various versions of Yosemite and 
running a small program that logs NSFoundationVersionNumber to the console.

You could also refer to NSObjCRuntime.h from certain super secret beta versions 
of future stuff, but gosh, I’d never talk about that here.

> But even if you were going to use such an approach (which seems unwise, as 
> you said yourself, considering NSProcessInfo), why on earth would you do a 
> greater-than comparison against the "today's last known version" of 10.10.x, 
> rather than a greater-than-or-equal-to comparison against what you can today 
> observe is exposed by 10.11.0?

The traditional way to use a version-specific feature has been like this:

if (floor(NSFoundationVersionNumber) > NSFoundationNumber10_9) {
        // do some Yosemite-specific thing
} else {
        // do some old-fashioned thing
}

The reason is that, as you’ve noticed, Apple never includes a constant for the 
currently shipping version of OS X, only for previous ones. (And also that 
doing a greater-than-or-equal check is problematic with floating-point numbers.)

NSProcessInfo is nice, but of course it only has the method that returns that 
info in Yosemite and greater, so if you want to support Mavericks or earlier, 
you have to check for the existence of that method before you use it, which 
makes the traditional method easier to use. Or at least it would be, if it 
worked. It doesn’t.

Charles


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to