Skip to content

Commit

Permalink
Fix issue #3, nil device causes crash when running on simulator. Now,…
Browse files Browse the repository at this point in the history
… error is printed.
  • Loading branch information
kkieffer committed Nov 13, 2019
1 parent 303a10d commit cb0a87f
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion ALCameraViewController/Views/CameraView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@ public class CameraView: UIView {
session.sessionPreset = AVCaptureSession.Preset.photo

device = cameraWithPosition(position: currentPosition)
if let device = device , device.hasFlash {
if device == nil {
print("Error: No Camera device found")
return
}

if device.hasFlash {
do {
try device.lockForConfiguration()
device.flashMode = .auto
Expand Down

0 comments on commit cb0a87f

Please sign in to comment.