以 NSException 类型的未捕获异常终止 - 以编程方式导航到另一个视图控制器

Terminating with uncaught exception of type NSException- Navigating to Another View Controller Programmatically

当我点击按钮时,我想以编程方式调出公司详细信息视图控制器(不使用故事板),但是我收到按钮功能的 NSException 错误。我相信 CompanyDetailsViewController() 是空的,我不确定为什么,因为我创建了一个名为 CompanyDetailsViewController

的 class
func detailsButtonTapped(sender: UIButton!) {
    let companyDetailsViewController = CompanyDetailsViewController()
    self.navigationController?.pushViewController(companyDetailsViewController, animated: true)
}

公司详细信息视图控制器Class

import UIKit

class CompanyDetailsViewController: UIViewController,UITableViewDelegate, UITableViewDataSource {
 var tableView: UITableView  =   UITableView()
 let animals : [String] = ["Dogs","Cats","Mice"]

  override func viewDidLoad() {
    super.viewDidLoad()
    view.backgroundColor = UIColor.blue
  }

  //code for create table view, etc
}

已解决!这是按钮的选择器调用错误,因为我不知道选择器调用已更改为 Swift 3.

class CompanyViewController: UIViewController {
    override func viewDidLoad() {
        button.addTarget(self, action: #selector(CompanyViewController.detailsButtonTapped(button:)), for: .touchUpInside)    
    }


    func detailsButtonTapped(button: UIButton!) {
        let companyDetailsViewController = CompanyDetailsViewController()
        self.navigationController?.pushViewController(companyDetailsViewController, animated: true)
    }
}