title: Using UIImagePickerController to retrieve selected Image in photo Library
body: <p>I have a little problem using UIImagePickerController... I would like to use the image selected by user from the iPhone library and use it when instantiating my viewController:</p>
  
  <p>first the User has to click on the StartWithImage button :</p>
  
  <pre><code>-(IBAction)startWithImage:(UIButton *) sender
  {
      self.imgPicker = [[UIImagePickerController alloc] init];
      self.imgPicker.delegate = self;
      self.imgPicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
      [self presentModalViewController:self.imgPicker animated:YES];
  }
  
  - (void)imagePickerController:(UIImagePickerController *)imagePicker didFinishPickingMediaWithInfo:(NSDictionary *)info 
  {
      [self dismissModalViewControllerAnimated:YES];
      [imagePicker release];
      //UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];
      photo =(UIImage *) [info objectForKey:UIImagePickerControllerOriginalImage];
      //code for starting game
  }
  </code></pre>
  
  <p>this is how I instantiate my viewController : </p>
  
  <pre><code>imageSliderViewController = [[ImageSliderViewController alloc] initWithSize:colMax :rowMax:photo];
  </code></pre>
  
  <p>My view controller uses photo in the viewDidLoad like this :</p>
  
  <pre><code>CGImageRef cgImg = CGImageCreateWithImageInRect(photo.CGImage, CGRectMake(ox, oy, width-1, height-1));//-1 for block effect
  </code></pre>
  
  <p>I get a EXC_BAD_ACCESS error... </p>