views:

97

answers:

1

I have integrated a library that uses AVCaptureSession to capture a photo from the camera. As is the AVCaptureSession is only available on iOS4 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 existance. Weak-linking is easy to do, but which function should I check for existance here? AVCaptureSession is a class and not a function.

Could anyone provide some sample code here please?

thanks in advance!

+1  A: 

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")) {
    ...
}
bosmacs
It worked! thanks alot. For note, I had to also weak-link other libraries like CoreVideo and UIKit.
adranale