title: How to open and select a photo from a photo gallery once user presses a button (save)
body: <p>I've looked everywhere but can't seem to find a suitable solution for saving and using a photo. I am building a basic application where a user has to select an image that later would be added to an array of UIImage object. This application consist of a table view consisting of cities that the user has been and a description. The user has the ability to add a new city, description, and image. When adding a new image I went and did a alertController </p>
  
  <pre><code>@IBAction func addCity(_ sender: AnyObject) {
      let alertController = UIAlertController(title: "Add new city", message: "", preferredStyle: UIAlertController.Style.alert)
  
      alertController.addTextField { (textField : UITextField!) -&gt; Void in
          textField.placeholder = "Enter City Name"
      }
      let saveAction = UIAlertAction(title: "Save", style: UIAlertAction.Style.default, handler: { alert -&gt; Void in
          let firstTextField = alertController.textFields![0] as UITextField
          let secondTextField = alertController.textFields![1] as UITextField
  
          self.newCity = firstTextField.text!
          self.city.addCity(city: self.newCity)
  
          self.newDescription = secondTextField.text!
          self.fruitTable.reloadData()
  
          if UIImagePickerController.isSourceTypeAvailable(UIImagePickerController.SourceType.photoLibrary
              ){
              print("Button capture")
  
              var imagePicker = UIImagePickerController()
              imagePicker.delegate = self as? UIImagePickerControllerDelegate &amp; UINavigationControllerDelegate
              imagePicker.sourceType = UIImagePickerController.SourceType.photoLibrary;
              imagePicker.allowsEditing = false
  
              self.present(imagePicker, animated: true, completion: nil)
          }
  
          func imagePickerController(picker: UIImagePickerController!, didFinishPickingImage image: UIImage!, editingInfo: NSDictionary!){
              self.dismiss(animated: true, completion: { () -&gt; Void in
  
              })
  
              self.newImage = image
          }
      })
      let cancelAction = UIAlertAction(title: "Cancel", style: UIAlertAction.Style.default, handler: {
          (action : UIAlertAction!) -&gt; Void in })
      alertController.addTextField { (textField : UITextField!) -&gt; Void in
          textField.placeholder = "Enter Description"
      }
  
      alertController.addAction(saveAction)
      alertController.addAction(cancelAction)
  
      self.present(alertController, animated: true, completion: nil)
  }
  </code></pre>
  
  <p>Through the segue I transfer all the information to the another view control, but when selecting a photo that information doesn't transfer over. I would like to know how to add the photo selected be added to the UIImage array.</p>
  
  <p>I could upload all my code if you wish but it is a lot. I know this seems confusing so if you have any questions please ask. Thank you!</p>