开发者

How do you use weak linking in an iPhone application?

开发者 https://www.devze.com 2023-02-09 07:03 出处:网络
How do you weak link frameworks when developing for the iPhone? Once you\'ve weak-linked a framework, how do you use classes and methods that may not be present 开发者_如何学Pythonon all OS versions?

How do you weak link frameworks when developing for the iPhone?

Once you've weak-linked a framework, how do you use classes and methods that may not be present 开发者_如何学Pythonon all OS versions?


What do you want to use weak Linking for?

A common use is to use a class defined only in a newer version of the SDK. The framework exists on older systems, but a class defined in the framework doesn't.

If this is the case then use NSClassFromString(). If it returns nil, the class doesn't exist, otherwise it will return the class object which can be used.

This is the recommended way according to Apple in this document:

0

精彩评论

暂无评论...
验证码 换一张
取 消