I'm trying to turn off an image in my torch app if the device doesn't support LED dimming.
NSError* outError;
BOOL success = [device setTorchModeOnWithLevel:brightnessLevel error:&outError];
if(!success){
[self.lightDialIndicator setHidden: YES];
self.lightDial.image = [UIImage imageNamed:@"light_dial_disabled.png"];
}
but my app crashed with the following error
[AVCaptureFigVideoDevice setTorchModeOnWithLevel:error:]: unrecognized selector sent to instance 0x73ad460
Any idea of a better/working way of detecting when the device doesn't allow me to use setTorchModeOnWithLevel?
First off,
setTorchModeOnWithLevelis a property on theAVCaptureDeviceclass.Second, if you want to test if a class can respond to a certain selector that you're calling on it, you use this:
You didn't show how you instantiated
devicein your example, but this applies to any class where you're unsure of whether it has a certain method or not.