I am a beginner of Swift.  

Currently, I am using AVFoundation to create camera applications.  

I am coding from Processing A to Processing B.  

However, the following error was displayed.  

Error:

> 
> Missing return in a function expected to return 'UIImage'. 
> 
> 
> 

I do not know how to use return in the `switch` statement. 

```
//Processing A
func captureImage(_ sampleBuffer: CMSampleBuffer) -> UIImage {
    .....
    switch self.input.device.position {
        case .front:
            let resultImage = UIImage(cgImage: imageRef, scale: 1.0, orientation: UIImageOrientation.down)
            return resultImage
        case .back:
            let resultImage = UIImage(cgImage: imageRef, scale: 1.0, orientation: UIImageOrientation.up)
            return resultImage
        default:
            print("error")
    }
}

```

![enter image description here](https://i.stack.imgur.com/Uzkgk.png)