title: how to switch camera recording session AVfoundation?
body: <p>i have a session to recording, but when I change the camera, this only save the firstly video from first camera, then swith not save, How can I do this?</p>
  
  <p>I use this function to switch and load new camera:</p>
  
  <pre><code> - (IBAction)switchCameras:(id)sender
  
  AVCaptureDevicePosition desiredPosition;
  if (isUsingFrontFacingCamera)
      desiredPosition = AVCaptureDevicePositionBack;
  else
      desiredPosition = AVCaptureDevicePositionFront;
  
  for (AVCaptureDevice *d in [AVCaptureDevice devicesWithMediaType:AVMediaTypeVideo]) {
      if ([d position] == desiredPosition) {
          [[previewLayer session] beginConfiguration];
          AVCaptureDeviceInput *input = [AVCaptureDeviceInput deviceInputWithDevice:d error:nil];
          for (AVCaptureInput *oldInput in [[previewLayer session] inputs]) {
              [[previewLayer session] removeInput:oldInput];
          }
          [[previewLayer session] addInput:input];
          [[previewLayer session] commitConfiguration];
          break;
      }
  }
  isUsingFrontFacingCamera = !isUsingFrontFacingCamera;
   }
  </code></pre>
  
  <p>Thanks!</p>