title: Swift 3 - Unable to execute a function
body: <p>Following is my code. I have also posted a screenshot. </p>
  
  <p>Button_CustomSegmentValueChanged is a custom Segmented control which i have made. Its an individual button and is working fine but I want to run "Button_CustomSegmentValueChanged" function from inside "SwipedRight" function too, but i am unable to pass the correct switch value in order to do so. Need help with it. </p>
  
  <p>Anyone?</p>
  
  <pre><code>import UIKit
  
  class CredentialsViewController: UIViewController {
  
      @IBOutlet weak var loginView: UIView!
      @IBOutlet weak var signupView: UIView!
  
      var currentSelectedView = 0
  
      override func viewDidLoad() {
          super.viewDidLoad()
  
          let swipeR = UISwipeGestureRecognizer(target: self, action: #selector(CredentialsViewController.SwipedRight(swipe:)))
          swipeR.direction = .right
          view.addGestureRecognizer(swipeR)
  
          let swipeL = UISwipeGestureRecognizer(target: self, action: #selector(CredentialsViewController.SwipedLeft(swipe:)))
          swipeL.direction = .left
          view.addGestureRecognizer(swipeL)
  
          //Hide view
          signupView.transform = CGAffineTransform(translationX: signupView.frame.size.width, y: 0)
      }
  
      @IBAction func Button_CustomSegmentValueChanged(_ sender: CustomSegmentedControl) {
  
          switch sender.selectedSegmentIndex {
          case 0:
              LoadLoginView()
              break
  
          case 1:
              LoadSignupView()
              break
  
          default:
              break
          }
  
      }
  
      func SwipedRight(swipe : UISwipeGestureRecognizer){
          if currentSelectedView == 1 {
              Button_CustomSegmentValueChanged(0)
              //LoadLoginView()
          }
      }
  
      func SwipedLeft(swipe : UISwipeGestureRecognizer){
          if currentSelectedView == 0 {
              //LoadSignupView()
          }
  
      }
  
      func LoadLoginView(){
  
          UIView.animate(withDuration: 0.5, delay: 0, options: .curveEaseOut, animations: {
              self.signupView.transform = CGAffineTransform(translationX : self.loginView.frame.size.width, y : 0)
              self.loginView.transform = .identity
              self.currentSelectedView = 0
          })
      }
  
      func LoadSignupView(){
  
          UIView.animate(withDuration: 0.5, delay: 0, options: .curveEaseOut, animations: {
              self.signupView.transform = .identity
              self.loginView.transform = CGAffineTransform(translationX: self.loginView.frame.size.width, y: 0)
              self.currentSelectedView = 1
          })
      }
  
  
  }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/Aj475.jpg" rel="nofollow noreferrer">Screenshot of my code and error</a></p>