title: How to display picked image in a uiimageview taken from the photo library to another uiimageview in a different view controller?
body: <p>So far this is my code, It allows me to pick a photo from the photo gallery and display it in an image view in one controller, the view controller has a button which has a segue that sends it to the next view controller in this view controller is another image view. </p>
  
  <p>I want the image view in the first controller to be displayed in the second imageview in the second view controller this is my code so far. </p>
  
  <p>I am not sure what steps to take to implement this so any help in steps to take would be appreciated, I tried various things but I think I'm not doing it so right, so i decided to give it a clean slate and get some advice</p>
  
  <p>Viewcontroller.h</p>
  
  <pre><code>#import &lt;UIKit/UIKit.h&gt;
  
  
  @interface ViewController : UIViewController &lt;UIImagePickerControllerDelegate,  UINavigationControllerDelegate&gt;
  @property (weak, nonatomic) IBOutlet UIImageView *imageView;
  @property (strong, nonatomic) UIImage *chosenImage;
  
  @property(strong, nonatomic) UIImagePickerController *imagePicker;
  
  
  @end
  </code></pre>
  
  <p>Viewcontroller.m</p>
  
  <pre><code>#import "ViewController.h"
  
  
  @interface ViewController ()
  
  @end
  
  
  @implementation ViewController
  
  - (void)viewDidLoad
  {
      [super viewDidLoad];
      NSString *myGrabbedImage = @"myGrabbedImage.png";
      NSArray *path = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,          NSUserDomainMask, YES);
      NSString *documentDirectory = [path objectAtIndex:0];
      NSString *fullPath = [documentDirectory stringByAppendingPathComponent:myGrabbedImage];
      NSData *data = [NSData dataWithContentsOfFile:fullPath];
      [[self imageView]setImage:[UIImage imageWithData:data]];
  }
  - (IBAction)chooseImage:(id)sender
  {
      self.imagePicker = [[UIImagePickerController alloc]init];
      self.imagePicker.delegate = self;
      [self.imagePicker setSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
      [self presentViewController:self.imagePicker animated:YES completion:nil];
  }
  
  -(void) imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
  {
      self.chosenImage = info[UIImagePickerControllerOriginalImage];
  
      NSData *data = UIImagePNGRepresentation(self.chosenImage);
      NSString *myGrabbedImage = @"myGrabbedImage.png";
      NSArray *path = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
      NSString *documentDirectory = [path objectAtIndex:0];
  
      [self.imageView setImage:self.chosenImage];
      [self dismissViewControllerAnimated:YES completion:nil];
      NSString *fullPathToFile = [documentDirectory stringByAppendingPathComponent:myGrabbedImage];
      [data writeToFile:fullPathToFile atomically:YES];
  
  
  }
  
  
  - (void) imagePickerControllerDidCancel:(UIImagePickerController *)picker
  {
      [self dismissViewControllerAnimated:YES completion:nil];
  }
  
  - (void)didReceiveMemoryWarning
  {
      [super didReceiveMemoryWarning];
  
  }
  
  
  
  
  @end
  </code></pre>