How to link Device Frameworks dynamically in iOS app?
Now My app is using Assets library Frameworks which is only available on iOS 4.0 and later for multi-choosing photos, but I want my app runs on devices with iOS 3.2.
Could I link the Assets library dynamically? If so I could judge开发者_开发知识库 whether the iOS SDK version is earlier than 4.0, if earlier I would use UIImagePickerController instead of Assets library, if later I could load Assets library dynamically and implement multi-choosing using it.
You can set the framework to weak linking. When you select a framework in Xcode 4 you can switch the target membership in the right pane between optional / required.
You should read Adding Runtime Checks for Newer Symbols in the docs.
Basically you can check the runtime availability of a class :
if ([INeedThisClass class]) ... // SDK 4.2 and later
or
Classe ineedthis = NSClassFromString(@"INeedThisClass"); // SDK 4.1
if (ineedthis) ...
精彩评论