Since AVCaptureDevice.devices is depreciated in iOS 10, I am trying to adjust this example code to AVCaptureDeviceDiscoverySession.
var error: NSError?
var captureSession: AVCaptureSession?
var backVideoDevice: AVCaptureDevice?
//let videoDevices = AVCaptureDevice.devices(withMediaType: AVMediaTypeVideo) // .devices DEPRECIATED
//iOS 10
let videoDevices = AVCaptureDeviceDiscoverySession(deviceTypes: [.builtInWideAngleCamera], mediaType: AVMediaTypeVideo, position: .back)
// Get back video device
if let videoDevices = videoDevices
{
for captureDevice in videoDevices
{
if (captureDevice as AnyObject).position == AVCaptureDevicePosition.back
{
backVideoDevice = captureDevice as? AVCaptureDevice
break
}
}
}
And here I am stuck, a error comes up at this line
for captureDevice in videoDevices
at the point videoDevices and says: Type 'AVCaptureDeviceDiscoverySession' does not conform to protocol 'Sequence'.
Where or what do I miss or oversee? Thx.