title: Transfer String from viewcontroller1 to viewcontroller2 and show barcode scan(String) in textbox of uiwebview
body: <p>I have a barcodescanner in one viewcontroller and a uiwebview in a second viewcontroller. How can i get the string which was created in the first viewcontroller catch in the second viewcontroller. I tried several things and tested it with nslog but it always shows me (nil) for the string value. Help me please out of this.</p>
  
  <p>Here is my code:</p>
  
  <p>igViewController.m:</p>
  
  <pre><code>#import &lt;AVFoundation/AVFoundation.h&gt;
  #import "igViewController.h"
  #import "ViewController.h"
  
  
  @interface igViewController () &lt;AVCaptureMetadataOutputObjectsDelegate&gt;
  {
      AVCaptureSession *_session;
      AVCaptureDevice *_device;
      AVCaptureDeviceInput *_input;
      AVCaptureMetadataOutput *_output;
      AVCaptureVideoPreviewLayer *_prevLayer;
  
      UIView *_highlightView;
     }
  @end
  
  @implementation igViewController
  @synthesize detectionString;
  @synthesize delegate;
  @synthesize thedetected;
  - (void)viewDidLoad
  {
      [super viewDidLoad];
  
      _highlightView = [[UIView alloc] init];
      _highlightView.autoresizingMask = UIViewAutoresizingFlexibleTopMargin|UIViewAutoresizingFlexibleLeftMargin|UIViewAutoresizingFlexibleRightMargin|UIViewAutoresizingFlexibleBottomMargin;
      _highlightView.layer.borderColor = [UIColor greenColor].CGColor;
      _highlightView.layer.borderWidth = 3;
      [self.view addSubview:_highlightView];
  
      _label = [[UILabel alloc] init];
      _label.frame = CGRectMake(0, self.view.bounds.size.height - 40, self.view.bounds.size.width, 40);
      _label.autoresizingMask = UIViewAutoresizingFlexibleTopMargin;
      _label.backgroundColor = [UIColor colorWithWhite:0.15 alpha:0.65];
      _label.textColor = [UIColor whiteColor];
      _label.textAlignment = NSTextAlignmentCenter;
      _label.text = @"(nichts)";
      [self.view addSubview:_label];
  
      _session = [[AVCaptureSession alloc] init];
      _device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
      NSError *error = nil;
  
      _input = [AVCaptureDeviceInput deviceInputWithDevice:_device error:&amp;error];
      if (_input) {
          [_session addInput:_input];
      } else {
          NSLog(@"Error: %@", error);
      }
  
      _output = [[AVCaptureMetadataOutput alloc] init];
      [_output setMetadataObjectsDelegate:self queue:dispatch_get_main_queue()];
      [_session addOutput:_output];
  
      _output.metadataObjectTypes = [_output availableMetadataObjectTypes];
  
      _prevLayer = [AVCaptureVideoPreviewLayer layerWithSession:_session];
      _prevLayer.frame = self.view.bounds;
      _prevLayer.videoGravity = AVLayerVideoGravityResizeAspectFill;
      [self.view.layer addSublayer:_prevLayer];
  
      [_session startRunning];
  
      [self.view bringSubviewToFront:_highlightView];
      [self.view bringSubviewToFront:_label];
  
  
  }
  -(void) viewWillAppear:(BOOL)animated{
      if(detectionString!=nil){
  
          UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
          UIViewController *top = [UIApplication sharedApplication].keyWindow.rootViewController;
  
          UIViewController *vc = [mainStoryboard instantiateViewControllerWithIdentifier:@"Controller1"];
          [top presentViewController:vc animated:YES completion:nil];
      }
  
  }
  
  
  - (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputMetadataObjects:(NSArray *)metadataObjects fromConnection:(AVCaptureConnection *)connection
  {
      CGRect highlightViewRect = CGRectZero;
      AVMetadataMachineReadableCodeObject *barCodeObject;
      detectionString = nil;
      NSArray *barCodeTypes = @[AVMetadataObjectTypeUPCECode, AVMetadataObjectTypeCode39Code, AVMetadataObjectTypeCode39Mod43Code,
              AVMetadataObjectTypeEAN13Code, AVMetadataObjectTypeEAN8Code, AVMetadataObjectTypeCode93Code, AVMetadataObjectTypeCode128Code,
              AVMetadataObjectTypePDF417Code, AVMetadataObjectTypeQRCode, AVMetadataObjectTypeAztecCode];
  
      for (AVMetadataObject *metadata in metadataObjects) {
          for (NSString *type in barCodeTypes) {
              if ([metadata.type isEqualToString:type])
              {
                  barCodeObject = (AVMetadataMachineReadableCodeObject *)[_prevLayer transformedMetadataObjectForMetadataObject:(AVMetadataMachineReadableCodeObject *)metadata];
                  highlightViewRect = barCodeObject.bounds;
                  detectionString = [(AVMetadataMachineReadableCodeObject *)metadata stringValue];
                  setSomeNumber:[(AVMetadataMachineReadableCodeObject *)metadata stringValue];
                  break;
              }
          }
  
          if (detectionString != nil)
          {
              _label.text = detectionString;
            // ViewController *otherViewController=[[ViewController alloc] init];
  
              UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
              UIViewController *vc = [mainStoryboard instantiateViewControllerWithIdentifier:@"Controller1"];
              ViewController *otherViewController=[[ViewController alloc] init];
  
              [otherViewController barcodeverarbeiten:detectionString];
              NSLog(@"detectionstringssssss %@", detectionString);
  
              [self presentViewController:vc animated:YES completion:nil];
  
  
              break;
          }
          else
              _label.text = @"(nichts)";
      }
  
      _highlightView.frame = highlightViewRect;
  }
  - (void)setSomeNumber:(NSString *)tempString {
      _label.text = tempString;
  }
  -(NSString *) thedetected{
  
  
      return _label.text;
  }
  
  @end
  </code></pre>
  
  <p>ViewController.m (only webViewDidFinishLoad</p>
  
  <pre><code>-(void) webViewDidFinishLoad:(UIWebView *)awebView{
          NSLog(@"detectionstring %@", otherViewController1.thedetected);
          if(otherViewController1.thedetected != nil){ //denk an self. ... bei igviewcontroller
  
  
          [self.Webseite stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:@"document.getElementsByName('SEARCH_STRING_CONTENT')[0].value = '%@';",otherViewController1.thedetected]];
      NSString *evalStr = [NSString stringWithFormat:@"setTimeout( function(){document.getElementsByName(SEARCH_STRING_CONTENT')[0].focus();},1000);"];
      [self.Webseite stringByEvaluatingJavaScriptFromString:evalStr];
  
      [self.Webseite stringByEvaluatingJavaScriptFromString:@"document.getElementsByClassName('buttonLinks searchButton withValue')[0].click();"];
  
      }
      [UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
              if ([awebView canGoBack] == YES){
          [backButton setEnabled:YES];
      }else{
          [backButton setEnabled:NO];
      }
      if([awebView canGoForward] == YES){
          [forwardButton setEnabled:YES];
      }else{
          [forwardButton setEnabled:NO];
      }
  
  }
  </code></pre>
  
  <p>igViewController.h:</p>
  
  <pre><code>#import &lt;UIKit/UIKit.h&gt;
  @class ViewController;
  @interface igViewController : UIViewController{
      ViewController *delegate;
  @public
  UILabel *_label;
      NSString *detectionString;
      //NSString *tempString;
  
  }
  @property (nonatomic, strong)NSString *detectionString;
  @property (nonatomic, strong) ViewController *delegate;
  @property (nonatomic, strong) NSString *thedetected;
  //@property (nonatomic, strong)NSString *tempString;
  - (void)setSomeNumber:(NSString *)tempString;
  @end
  </code></pre>
  
  <p>ViewController.h:</p>
  
  <pre><code>#import &lt;UIKit/UIKit.h&gt;
  #import "FavoritenController.h"
  @class igViewController;
  
  
  @interface ViewController : UIViewController &lt;UITextFieldDelegate, UIWebViewDelegate, UIActionSheetDelegate&gt;
  
  {
  
  
      UIWebView *Webseite;
      UIBarButtonItem *backButton;
      UIBarButtonItem *forwardButton;
      UITextField *textField;
      UIBarButtonItem *refreshButton;
      NSString* urlBeforeEditing;
      UIBarButtonItem *barcodescan;
      igViewController *otherViewController1;
  
      FavoritenController* favoritenController;
             /* ..*/
  
  }
  @property  (nonatomic, retain) IBOutlet UIBarButtonItem *barcodescan;
  
  @property (nonatomic, strong)     igViewController *otherViewController1;
  @property (nonatomic, retain) IBOutlet UITextField *textField;
  @property (weak, nonatomic) IBOutlet UIBarButtonItem *onlinetauscher;
  @property (nonatomic, retain) IBOutlet UIWebView *Webseite;
  @property ( nonatomic, retain) IBOutlet UIBarButtonItem *refreshButton;
  @property ( nonatomic, retain) IBOutlet UIBarButtonItem *backButton;
  @property (nonatomic, retain) IBOutlet UIBarButtonItem *forwardButton;
  - (IBAction)onlinetauscher:(UIBarButtonItem *)sender;
  
  - (IBAction)pressRefresh:(UIBarButtonItem *)sender;
  //- (IBAction)search:(id)sender;
  
  - (IBAction)zeigeMedikamente:(id)sender;
  - (IBAction)hinzufuegen:(id)sender;
  - (void)barcodeverarbeiten:(NSString*)barcodepzn;
  @end
  </code></pre>