title: Swift 4: Unrecognized selector sent to instance when calling a function inside another class
body: <p>For my application, I am working without storyboards. For that reason, I am trying to keep my ViewController clutter free by storing larger functions inside another class and calling them when needed. </p>
  
  <p>For some reason, when I call my functions with #Selector I get a crash stating "Unrecognized selector sent to instance". </p>
  
  <p>When I store my function inside the same ViewController as the #Selector it works just fine. </p>
  
  <p><strong>The Following Code Below Works</strong></p>
  
  <p><strong>View Controller</strong></p>
  
  <pre><code>class ViewController: UIViewController {
  
  override func viewDidLoad() {
      super.viewDidLoad()
  
      view.addSubview(loginRegisterButton)
  
  
  }
  
  lazy var loginRegisterButton: UIButton = {
      let button = UIButton(type: .system)
      button.backgroundColor = Color.darkBlue
      button.setTitle("Register", for: .normal)
      button.translatesAutoresizingMaskIntoConstraints = false
      button.setTitleColor(UIColor.white, for: .normal)
      button.layer.cornerRadius = 5
      button.titleLabel?.font = UIFont.boldSystemFont(ofSize: 16)
  
      button.addTarget(self, action: #selector(LoginFunctions.handleLogin), for: .touchUpInside)
  
      return button
  }()
  
      @objc func handleLogin() {
      print("Logging In!!!")
      }
  
  }
  </code></pre>
  
  <p><em>What I am trying to achieve</em></p>
  
  <p><strong>The code below does not work</strong></p>
  
  <p><strong>View Controller</strong></p>
  
  <pre><code>class ViewController: UIViewController {
  
  override func viewDidLoad() {
      super.viewDidLoad()
  
      view.addSubview(loginRegisterButton)
  
  
  }
  
  lazy var loginRegisterButton: UIButton = {
      let button = UIButton(type: .system)
      button.backgroundColor = Color.darkBlue
      button.setTitle("Register", for: .normal)
      button.translatesAutoresizingMaskIntoConstraints = false
      button.setTitleColor(UIColor.white, for: .normal)
      button.layer.cornerRadius = 5
      button.titleLabel?.font = UIFont.boldSystemFont(ofSize: 16)
  
      button.addTarget(self, action: #selector(LoginFunctions.handleLogin), for: .touchUpInside)
  
      return button
  }()
  
  }
  </code></pre>
  
  <p><strong>LoginFunctions</strong></p>
  
  <pre><code>import Foundation
  import UIKit
  
  class LoginFunctions {
  
  @objc func handleLogin() {
      print("Logging In!!!")
  }
  }
  </code></pre>
  
  <p>I have been trying to debug this for days with no luck. Any help would be greatly appreciated. Thanks in advance!</p>