-
Notifications
You must be signed in to change notification settings - Fork 677
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix/crash #28
Conversation
self.captureSession.sessionPreset = AVCaptureSessionPreset640x480 | ||
} | ||
|
||
try! self.captureSession.addInput(AVCaptureDeviceInput(device: self.captureDevice)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we use do { try without having to !?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why? for some reason It always leads to crash without even trying to go to "catch" part.
If user switches from front to back camera, a higher quality mode should be selected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, but my question was about, why you do try! instead of do { try?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because if it never catches error, there is no need to do { try
Or try to refactor it if you can. Maybe I did something wrong, but it kept crashing even when I've implemented catch {}
method
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When you use the try! keyword, you don't need to have do and catch around your code, because you're promising it won't ever fail.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zenangst yes. If I choose capture session device-specific, it won't fail. If it fails, app should terminate, but this case is impossible. All devices supporting iOS 8+ have camera at least better than 4S. This code works on 4S -> It should work everywhere.
Fix crash on 4S and other devices with low-resolution frontal camera. ImagePicker crashed when user tried to switch between frontal and back camera.
Refactored StackView, as there were no need to reinvent the suffix() function.