Commit ad2d1dca authored by Tobias Due Munk's avatar Tobias Due Munk

Fix crash when sharing appendix photos

parent b1f186f3
......@@ -127,8 +127,16 @@ class EditorViewController: UIViewController {
selectedEffect = segment.selectedSegmentIndex
}
private func effect(at index: Int) -> Effect {
if effects.indices.contains(index) {
return effects[index]
} else {
return appendices[index - effects.count]
}
}
@objc private func didRequestShare() {
guard let result = effects[selectedEffect](image, depthMap) else { return }
guard let result = effect(at: selectedEffect)(image, depthMap) else { return }
let context = CIContext()
let cgImage = context.createCGImage(result, from: result.extent)
let sharableImage = UIImage(cgImage: cgImage!)
......@@ -142,13 +150,7 @@ class EditorViewController: UIViewController {
private func update() {
originalImageView.image = UIImage(ciImage: image)
depthMapView.image = UIImage(ciImage: depthMap)
let effect: Effect
if effects.indices.contains(selectedEffect) {
effect = effects[selectedEffect]
} else {
effect = appendices[selectedEffect - effects.count]
}
guard let result = effect(image, depthMap) else {
guard let result = effect(at: selectedEffect)(image, depthMap) else {
let ac = UIAlertController(title: "No Output", message: "Effect #\(selectedEffect + 1) returned nil.", preferredStyle: .alert)
ac.addAction(UIAlertAction(title: "OK", style: .default))
present(ac, animated: true)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment