title: How do I separate these two functions?
body: <p>Right now when I click on the pick image action I pick an image and it goes directly to the database as soon as the image picker closes. How do I make it two different functions so that one button picks an image and the other uploads it?</p>
  
  <pre><code>@IBAction func pickImage(_ sender: Any) {
  
  
      let image = UIImagePickerController()
      image.delegate = self
      image.sourceType = UIImagePickerControllerSourceType.photoLibrary
  
      image.allowsEditing = false
  
      self.present(image, animated: true)
      {
          //after its completed
      }
  
  
  @objc(imagePickerController:didFinishPickingMediaWithInfo:) func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any])
  {
      if let image = info[UIImagePickerControllerOriginalImage] as? UIImage
      {
          myImageView.image = image
  
      }
      else
      {
          //error
      }
  
      self.dismiss(animated: true, completion: nil)
  
  
      let storageRef = Storage.storage().reference().child("images/\(NSUUID().uuidString)/image.png")
      if let uploadData = UIImagePNGRepresentation(self.myImageView.image!){
  
          storageRef.putData(uploadData, metadata: nil, completion:
              {
                  (metadata, error) in
                  if error != nil {
                      print("error")
                      return
                  }
  
                  else {
  
                      let downloadURL = metadata?.downloadURL()?.absoluteString
                      self.ref?.child("Posts").childByAutoId().setValue(["Title": self.titleText.text,"Article": self.mainText.text, "Author": self.authorText.text, "Date": self.dateText.text,  "Download URL": (downloadURL)])
  
               }                
          }                  
          )
      }
  </code></pre>