Skip to content
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

Merged
merged 3 commits into from
Sep 16, 2015
Merged

Fix/crash #28

merged 3 commits into from
Sep 16, 2015

Conversation

richardtop
Copy link
Contributor

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.

self.captureSession.sessionPreset = AVCaptureSessionPreset640x480
}

try! self.captureSession.addInput(AVCaptureDeviceInput(device: self.captureDevice))
Copy link
Contributor

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 !?

Copy link
Contributor Author

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.

Copy link
Contributor

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?

Copy link
Contributor Author

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

Copy link
Contributor

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.

Copy link
Contributor Author

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.

zenangst added a commit that referenced this pull request Sep 16, 2015
@zenangst zenangst merged commit c3001cd into swift-2.0 Sep 16, 2015
@zenangst zenangst deleted the fix/crash branch September 16, 2015 13:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants