title: Displaying "Try again" UIAlertView during critical initialization
body: <p>During the initialization of an app, I naturally have some critical things that have to be done to get the app running. For example, in this case I need to get the <code>AVCaptureDevice</code> pointer for the back camera.</p>
  
  <p>So if it fails, (which it never should, but you never know), I want to display a <code>UIAlertView</code> with only one option, "Try again". When the user selects this, the app will try to get the <code>AVCaptureDevice</code> again.</p>
  
  <p>The problem is that I need to wait for the user to press "Try again" before I continue, but <code>UIAlertView</code> is not modal.</p>
  
  <p>If there was only one piece of code like this, I could potentially handle it with the <code>UIAlertViewDelegate</code> callback. But since there will be multiple critical pieces of initialization like this, I don't see how I could use the callback without things getting really messy.</p>
  
  <p>Is there an elegant way to handle this?</p>
  
  <p>Edit: Some code:</p>
  
  <pre><code>- (void)setup
  {
      NSError *error = nil;
  
      // get all the video devices. (this should be the back camera and the front camera.)
      NSArray *videoDevices = [AVCaptureDevice devicesWithMediaType:AVMediaTypeVideo];
  
      AVCaptureDevice *backVideoDevice;
  
      // find the back camera.
      do 
      {
          for (AVCaptureDevice *videoDevice in videoDevices)
          {
              if (videoDevice.position == AVCaptureDevicePositionBack)
              {
                  backVideoDevice = videoDevice;
  
                  break;
              }
          }
  
          if (backVideoDevice == nil)
          {
              // display UIAlertView???
          }
  
      } while (backVideoDevice == nil);
  
      // if no back camera was found, then we can't continue.
  
      AVCaptureDeviceInput *videoDeviceInput = [AVCaptureDeviceInput deviceInputWithDevice:backVideoDevice error:&amp;error];
  
      AVCaptureStillImageOutput *stillImageOutput = [AVCaptureStillImageOutput new];
  
      AVCaptureSession *captureSession = [AVCaptureSession new];
  
      if ([captureSession canAddInput:videoDeviceInput])
      {
          [captureSession addInput:videoDeviceInput];
      }
  
      if ([captureSession canAddOutput:stillImageOutput])
      {
          [captureSession addOutput:stillImageOutput];
      }
  
      // etc, etc.
  }
  </code></pre>
  
  <p>Most of the steps will require checking if they succeeded, like the first one.</p>