Re: What is the equivalent of SetSystemUIMode() in Leopard and above?
Re: What is the equivalent of SetSystemUIMode() in Leopard and above?
- Subject: Re: What is the equivalent of SetSystemUIMode() in Leopard and above?
- From: Jean-Daniel Dupas <email@hidden>
- Date: Wed, 27 Jan 2010 12:01:37 +0100
Le 27 janv. 2010 à 11:48, Alastair Houghton a écrit :
> On 27 Jan 2010, at 05:36, Charles Srstka wrote:
>
>> Or you could just do something like this:
>>
>> if(floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_5)
>> {
>> [NSApp setPresentationOptions:whatever];
>> }
>> else
>> {
>> SetSystemUIMode(whatever);
>> }
>>
>> You could also use if([NSApp respondsToSelector:@selector(setPresentationOptions:)) if you prefer. I like to explicitly test for the version number though, so that once I *am* ready to say “10.6 and above”, it’s easy to search for and remove all the compatibility cruft that’s in there to make older versions work.
>
> That's an interesting point. Personally I prefer using -respondsToSelector: rather than version numbers, but I suppose it might be a good idea to stick a comment in a special form before the test; maybe something like
>
> // ###COMPAT 10.5
> if ([NSApp respondsToSelector:@selector(setPresentationOptions:)])
> [NSApp setPresentationOptions:whatever];
> else
> SetSystemUIMode (whatever);
>
> It isn't something I've spent a great deal of time considering, and I know as a result we probably have some cruft in our code in places to deal with compatibility for versions of OS X we no longer support.
>
> Kind regards,
>
> Alastair.
I also prefer this approach but it should be use with care as sometimes, a framework in a previous OS version "exports" private function/method with the same name but with a different behavior.
So, if you test for function existence, it always returns true, even on the OS version which contains a non-working version of the function.
This is rare, but I remember some cases in the Security framework which exports symbols declared as private and not implemented in an OS version and change these symbols as public in the following major version.
-- Jean-Daniel
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden