0

I have this code, first written a few years ago now. The following code embodies the warnings I'm getting and I can't seem to find the new method of implementing such a simple bit of code. I've been trying all sorts of things suggested by Apple Resources to no avail. This code still works, with warnings, but I suspect will soon not work at all. Is there a new method to 'setFlashMode'?

'isFlashModeSupported:' is deprecated: and 'setFlashMode:' is deprecated:

+ (void)setFlashMode:(AVCaptureFlashMode)flashMode forDevice:(AVCaptureDevice *)device
{

    if ([device hasFlash] && [device isFlashModeSupported:flashMode])
        {
        NSError *error = nil;
        if ([device lockForConfiguration:&error])
        {
            [device setFlashMode:flashMode];
            [device unlockForConfiguration];
        }
        else
        {
            NSLog(@"%@", error);
        }
    }
}

If I use from example 1 in Other Answer,

device.flashMode = AVCaptureFlashModeAuto; ...... 'flashMode' is deprecated:

Harry McGovern
  • 517
  • 5
  • 19
  • 2
    Possible duplicate of [AVCaptureDevice isFlashModeSupported deprecated iOS 10](https://stackoverflow.com/questions/47135071/avcapturedevice-isflashmodesupported-deprecated-ios-10) – Tamás Sengel May 09 '18 at 12:25
  • 1
    Sorry, it's not quite the same. I'm spending just as much time on this aas the original. – Harry McGovern May 09 '18 at 13:14

1 Answers1

-1

assign it directly..

device.flashMode = AVCaptureFlashModeAuto;

Nirav Kotecha
  • 2,493
  • 1
  • 12
  • 26
  • 1
    device.flashMode = AVCaptureFlashModeAuto; ......'flashMode' is deprecated: first deprecated in iOS 10.0 - Use AVCapturePhotoSettings.flashMode instead. – Harry McGovern May 09 '18 at 12:59