I have MyTableViewCell
class and their .xib
on my TableViewController
want to click button inside cell and then goto my other UIViewController
, UITableViewDataSource
, UITableViewDelegate
from this
class OverviewViewController: UITableViewController
{
override func viewDidLoad() {
super.viewDidLoad()
self.tableView.registerNib(UINib(nibName: "MyTableViewCell", bundle: nil), forCellReuseIdentifier: "MyTableViewCell")
}
To this
class HistoryController: UIViewController , UITableViewDataSource, UITableViewDelegate{
@IBOutlet var MyTable: UITableView!
override func viewDidLoad() {
super.viewDidLoad()
self.MyTable.registerNib(UINib(nibName: "HistoryTableViewCell", bundle: nil), forCellReuseIdentifier: "HistoryTableViewCell")
}
historyBtn
in MyTableViewCell
an I use that
....
cell.historyBtn.tag = indexPath.row
cell.historyBtn.addTarget(self, action: "getHistoryList", forControlEvents: UIControlEvents.TouchUpInside)
....
My HistoryList Method
func getHistoryList()
{
presentViewController(HistoryController(), animated: true, completion: nil)
}
But when go to the HistoryController
I get this error :
unexpectedly found nil while unwrapping an Optional value
MyTableView nil