iPhone checking for existence of AVCaptureSession Class

佐手、 提交于 2019-12-06 14:56:17

问题


I have integrated a library that uses AVCaptureSession to capture a photo from the camera. As the AVCaptureSession is only available on iOS 4 devices, I want to disable this integrated functionality for older devices.

I know that it should be done by weak-linking the AVFoundation Framework and checking for function existence. Weak-linking is easy to do, but which function should I check for existence here? AVCaptureSession is a class and not a function.

Are there some sample code available?


回答1:


I think you're looking for NSClassFromString:

Class NSClassFromString ( NSString *aClassName );

You can then guard usage of that class with something like this:

if (NSClassFromString(@"AVCaptureSession")) {
    ...
}


来源:https://stackoverflow.com/questions/3736413/iphone-checking-for-existence-of-avcapturesession-class

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