iPhone checking for existence of AVCaptureSession

2019-04-17 10:21发布

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条回答
forever°为你锁心
2楼-- · 2019-04-17 10:55

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")) {
    ...
}
查看更多
登录 后发表回答