FullScreenCamera
FullScreenCamera copied to clipboard
Value of type '[AVCaptureDevice]' has no member 'compactMap'
let cameras = session.devices.compactMap { $0 }
- error on this line
Updated to Swift 4.1, error is gone but getting cameras as anempty array.
Try to replace:
let session = AVCaptureDevice.DiscoverySession(deviceTypes: [.builtInDualCamera], mediaType: AVMediaType.video, position: .unspecified)
By:
let session = AVCaptureDevice.DiscoverySession(deviceTypes: [.builtInWideAngleCamera], mediaType: AVMediaType.video, position: .unspecified)
Still getting the same error...
Could someone one please help... THANKYOU in advance..
Try to use something like this.
let cameras = (sessions.devices.flatMap { $0 })
@sri1sri generic instance method compactMap seems to be supported from iOS 7.0+ and compatible with Xcode 9.3+ . What is the SDK version you are targeting and Xcode version you are using ?
Still getting the same error...
-
Use
as? [AVCaptureDevice]
at the end of.compact { $0 }
-
` let session = AVCaptureDevice.DiscoverySession(deviceTypes: [.builtInWideAngleCamera], mediaType: AVMediaType.video, position: .unspecified)
let cameras = session.devices.compactMap { $0 } guard !cameras.isEmpty else { throw CameraControllerError.noCamerasAvailable }`