title: How to allow user to pick the image with Swift?
body: <p>I am writing my first iOS application (iPhone only) with Swift. The main application view should allow user to choose the image from the photo gallery. </p>
  
  <p>I've found the following sample code of <strong>ViewController.swift</strong>:</p>
  
  <pre><code>class ViewController: UIImagePickerController, UINavigationControllerDelegate, UIImagePickerControllerDelegate  {
  
      override func viewDidLoad() {
          super.viewDidLoad()
          // Do any additional setup after loading the view, typically from a nib.
      }
  
      override func didReceiveMemoryWarning() {
          super.didReceiveMemoryWarning()
          // Dispose of any resources that can be recreated.
      }
  
      func tableView(tableView: UITableView!, didSelectRowAtIndexPath indexPath: NSIndexPath!) {
  
          var imagePickerController = UIImagePickerController()
          imagePickerController.delegate = self
          imagePickerController.sourceType = UIImagePickerControllerSourceType.SavedPhotosAlbum
          imagePickerController.allowsEditing = true
          self.presentViewController(imagePickerController, animated: true, completion: { imageP in
  
          })
      }
  
  
      func imagePickerController(picker: UIImagePickerController!, didFinishPickingImage image: UIImage!, editingInfo: NSDictionary!) {
          let selectedImage : UIImage = image
          println(selectedImage)
      }
  
  }
  </code></pre>
  
  <p>and have the following View Controller Scene -</p>
  
  <pre><code>View Controller
   - Top Layout Guide
   - Bottom Layout Guide
   - View
     - Image View
  First Responder
  Exit
  </code></pre>
  
  <p>But when I start the app, just black screen is shown. What I am doing wrong?
  Another <a href="https://developer.apple.com/library/prerelease/ios/samplecode/PhotoPicker/Listings/PhotoPicker_APLViewController_m.html#//apple_ref/doc/uid/DTS40010196-PhotoPicker_APLViewController_m-DontLinkElementID_6">sample code</a> I've found is in Objective-C, which doesn't help me.</p>