title: How to create a QR Code reader for iOS
body: <p>I am developing an app for our local business. I already have the live camera in a <code>UIImageView</code>, now I need to know how to read QR codes from the <code>UIImageView</code> and display the content (0000-KKP0-2013) in a label.</p>
  
  <p>So basically I need a QR code scanner which is reading a QR code and save the content in a String. I already used ZXing ("Zebra Crossing") but it is not compatible with iOS 6 and it won't work. Is there an easy code for getting the QR Code content in a String?</p>
  
  <p>Thank you!</p>
  
  <p>This is the code I am using in my .m file: </p>
  
  <pre><code>#import "ZBarSDK.h"
  
  @interface ViewController ()
  
  @end
  
  @implementation ViewController
  
  @synthesize vImagePreview;             
  
  - (void)viewDidUnload
  {
      [super viewDidUnload];
  
      vImagePreview = nil;
  }
  
  - (void)viewDidAppear:(BOOL)animated
  {
      [super viewDidAppear:animated];
  
  
      //----- SHOW LIVE CAMERA PREVIEW -----
      AVCaptureSession *session = [[AVCaptureSession alloc] init];
      session.sessionPreset = AVCaptureSessionPreset352x288;
  
      /*CALayer *viewLayer = self.vImagePreview.layer;
      NSLog(@"viewLayer = %@", viewLayer);*/
  
      AVCaptureVideoPreviewLayer *captureVideoPreviewLayer = [[AVCaptureVideoPreviewLayer alloc] initWithSession:session];
  
      captureVideoPreviewLayer.frame = self.vImagePreview.bounds;
      [self.vImagePreview.layer addSublayer:captureVideoPreviewLayer];
  
      AVCaptureDevice *device = [self frontCamera];
  
      NSError *error = nil;
      AVCaptureDeviceInput *input = [AVCaptureDeviceInput deviceInputWithDevice:device error:&amp;error];
      if (!input) {
          // Handle the error appropriately.
          NSLog(@"ERROR: trying to open camera: %@", error);
  
          UIAlertView *alert = [[UIAlertView alloc]
                                initWithTitle:@"QReader"
                                message:[NSString stringWithFormat:@"ERROR: Versuch die Kamera zu öffnen ist fehlgeschlagen [%@]",error]
                                delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
  
          alert.tag = 1;
  
          [alert show];
      }
      [session addInput:input];
  
      [session startRunning];
  
      }
  
  - (AVCaptureDevice *)frontCamera {
      NSArray *devices = [AVCaptureDevice devicesWithMediaType:AVMediaTypeVideo];
      for (AVCaptureDevice *device in devices) {
          if ([device position] == AVCaptureDevicePositionFront) {
              return device;
          }
      }
      return nil;
  }
  </code></pre>
  
  <p>Now I need to know how to read the QR code from the vImagePreview with the ZBarSDK. And I cant use a UIPickerView</p>