问题
I have an app that is being compiled with a minimum system requirement of Tiger (OS X 10.4), but I need to include some code to deal with Spaces if the app is executing on Leopard (OS X 10.5).
How do I do this?
(The call I need to make is to -[NSWindow setCollectionBehavior:]
).
回答1:
- Set your Base SDK (for all configurations of the target you're building) to the version of the OS that includes the call.
- Set the Deployment Version to the earliest OS you want your code to launch on.
- For all calls that don't exist in earlier versions of the OS, you must test before you call, either by using respondsToSelector: (for methods) or testing against nil (for functions and statics). You can if you like do a check for the OS version, but it's more robust to check the specific call.
The Cross-Development Programming Guide describes the techniques in detail.
来源:https://stackoverflow.com/questions/1014427/how-do-i-include-calls-to-methods-only-present-in-one-operating-system-version-w