title: "fatal error: unexpectedly found nil while unwrapping an Optional value" for image View
body: <p>I have one view, there is one button and one ImageView. When pressed, the button triggers UIImagePickerController and the UIView will display the picked image. I tried to do this <strong>without using storyboard</strong>, but I keep getting a <code>"fatal error: unexpectedly found nil while unwrapping an Optional value"</code> at this line <code>imageView.contentMode = .ScaleAspectFit</code>. I've looked at other stackoverflow posts that suggest using <code>editingInfo[UIImagePickerControllerOriginalImage]</code> instead of <code>info[UIImagePickerControllerOriginalImage]</code>, but it hasn't worked. How do you fix this issue?</p>
  
  
  
  <pre><code>import UIKit
  
  class EditViewController: UIViewController, UIImagePickerControllerDelegate, UINavigationControllerDelegate {
  
  var imageView: UIImageView!=nil
  
  override func viewDidLoad() {
      super.viewDidLoad()
      createBackground()
      createImageView()
      createButton()
  }
  
  override func didReceiveMemoryWarning() {
      super.didReceiveMemoryWarning()
      // Dispose of any resources that can be recreated.
  }
  
  func createBackground() {
      let backgroundImage = UIImage(named: "pinetree")
      var imageView: UIImageView!
      imageView = UIImageView(frame: view.bounds)
      imageView.contentMode = .ScaleAspectFill
      imageView.clipsToBounds = true
      imageView.image = backgroundImage
      imageView.center = view.center
      view.addSubview(imageView)
      self.view.sendSubviewToBack(imageView)
  }
  
  func createImageView() {
      var image: UIImage!
      var imageView = UIImageView(image: image)
      imageView.frame = CGRectMake(view.bounds.width/2, view.bounds.height/2, view.bounds.width, view.bounds.height*(3/4))
      self.view.addSubview(imageView)
  }
  
  func createButton() {
      let size = view.bounds.width
      let cx = view.bounds.width/2
      let cy = view.bounds.height * 4/5
      let button = UIButton();
      button.frame = CGRectMake(0, 0, size, size)
      button.center.x = cx
      button.center.y = cy
      button.setTitle("Load Image", forState: .Normal)
      button.addTarget(self, action: "loadImageButtonPressed:", forControlEvents: .TouchUpInside)
      self.view.addSubview(button)
  }
  
  func loadImageButtonPressed(sender: UIButton!) {
      if UIImagePickerController.isSourceTypeAvailable(UIImagePickerControllerSourceType.PhotoLibrary){
          var imagePicker = UIImagePickerController()
          imagePicker.delegate = self
          imagePicker.sourceType = UIImagePickerControllerSourceType.PhotoLibrary;
          //imagePicker.mediaTypes = [kUTTypeImage];
          imagePicker.allowsEditing = false
          self.presentViewController(imagePicker, animated: true, completion: nil)
      }
  }
  
  func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : AnyObject]) {
      if let pickedImage = info[UIImagePickerControllerOriginalImage] as? UIImage {
          imageView.contentMode = .ScaleAspectFit
          imageView.image = pickedImage
      }
      dismissViewControllerAnimated(true, completion: nil)
  }
  
  func imagePickerControllerDidCancel(picker: UIImagePickerController) {
      dismissViewControllerAnimated(true, completion: nil)
  }
  
  }
  </code></pre>