检查类型'()MyMethodName'C语言函数的存在? [英] check if C-style function exists of type 'MyMethodName()'?
本文介绍了检查类型'()MyMethodName'C语言函数的存在?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
此问题是面向iOS的版本的兼容性。
This question is geared for iOS version compatibility.
我知道如何检查是否存在一个函数,如果它是一个使用respondsToSelector一个典型的Objective-C风格的方法。即,对于一个方法,如:
I know how to check if a function exists if it is a typical Objective-C style method using respondsToSelector. i.e. For a method such as:
- (void) someMethod:(NSInteger)someParameter;
您可以使用:
if ([self respondsToSelector:@selector(someMethod:someParameter)]) {
//do something
}
不过,关于C风格的功能是什么?如何检查是否函数存在,看起来像:
But what about C-style functions? How can I check if a function exists that looks like:
void CStyleFunctionName(FoundationTypeRef parameter);
谢谢!
推荐答案
X code(至少从4.3)支持弱链接,你可以做以下,看看是否可以调用C函数:
Xcode (at least since 4.3) supports weak linking and you can do the following to see if you can call a C function:
// UIGraphicsBeginImageContextWithOptions() was introduced in iOS 4 in order to support the Retina displays.
if (UIGraphicsBeginImageContextWithOptions != NULL) {
UIGraphicsBeginImageContextWithOptions(...);
}
else {
UIGraphicsBeginImageContext();
}
这篇关于检查类型'()MyMethodName'C语言函数的存在?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文