【Topics Generic】Supporting Multiple Versions of iOS
来源:互联网 发布:linux常用软件大全 编辑:程序博客网 时间:2024/04/28 18:38
Any app that supports a range of iOS versions must use runtime checks to prevent the use of newer APIs onolder versions of iOS that do not support them. For example, if you build your app using new features in iOS6 but your app still supports iOS 5, runtime checks allow you to use recently introduced features when theyare available and to follow alternate code paths when they are not. Failure to include such checks will causeyour app to crash when it tries to use new symbols that are not available on the older operating system.
There are several types of checks that you can make:
To determine whether a method is available on an existing class, use theinstancesRespondToSelector:class method or therespondsToSelector:instance method.
Apps that link against iOS SDK 4.2 and later can use the weak linking support introduced in that versionof the SDK. This support lets you check for the existence of a givenClassobject to determine whetheryou can use that class. For example:
●
●
if ([UIPrintInteractionController class]) { // Create an instance of the class and use it.
}else {
// The print interaction controller is not available.}
●
To use this feature, you must build your app using LLVM and Clang and the app’s deployment target mustbe set to iOS 3.1 or later.
Apps that link against iOS SDK 4.1 and earlier must use theNSClassFromStringfunction to see whethera class is defined. If the function returns a value other thannil, you may use the class. For example:
Class splitVCClass = NSClassFromString(@"UISplitViewController");if (splitVCClass){
UISplitViewController* mySplitViewController = [[splitVCClass alloc]init];
// Configure the split view controller.}
●
To determine whether a C-based function is available, perform a Boolean comparison of the function nametoNULL. If the symbol is notNULL, you can use the function. For example:
if (UIGraphicsBeginPDFPage != NULL){
UIGraphicsBeginPDFPage();}
For more information and examples of how to write code that supports multiple deployment targets, seeSDKCompatibility Guide.
- 【Topics Generic】Supporting Multiple Versions of iOS
- Supporting Multiple iOS Versions and Devices
- install ios simulators of multiple versions in xcode
- Install multiple versions of Python
- The Android Evolution of Supporting Multiple Screens
- Loading Multiple Versions of same Assembly
- using multiple versions of the SDK
- Supporting Different Devices - Supporting Different Platform Versions
- 《Training:Supporting Different Platform Versions》
- Supporting Multiple Screens
- Supporting Multiple Screens 翻译
- Supporting Multiple Screens
- Supporting Multiple Screens
- Supporting Multiple Interface Orientations
- Supporting Multiple Screens
- Supporting Multiple Screens
- Supporting Multiple Screens
- Supporting Multiple Screens
- Oracle查询表空间使用情况
- .gitignore 文件配置
- xcode missing file xxxx
- 设计模式之命令模式
- 阿里巴巴面试总结
- 【Topics Generic】Supporting Multiple Versions of iOS
- oracle 查看用户所在的表空间
- 最长递增子序列(输出最长递增序列 及其长度)
- 第十六章 16.1.1节练习
- JQuery文档学习-2
- 原发性肝癌有什么比较便宜的治疗方式?
- 京东商超频道上线的竞争力
- 新的xocde使用旧的模拟器
- iframe与主框架跨域相互访问方法