How do I include calls to methods only present in one operating system version when compiling for multiple versions?

时间秒杀一切 提交于 2019-12-24 21:12:19

问题


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:


  1. Set your Base SDK (for all configurations of the target you're building) to the version of the OS that includes the call.
  2. Set the Deployment Version to the earliest OS you want your code to launch on.
  3. 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!