Reputation: 745
I am trying to pass data from my table which is a xib file to a view controller but for some reason, the code is not working and throwing an error. I have also browsed the internet, yet not got the solution.
viewDidLoad Function
override func viewDidLoad() {
super.viewDidLoad()
dataPass()
self.navigationItem.title = "Landlord List"
propertyTabel.register(UINib(nibName: "PropertyCell", bundle: nil), forCellReuseIdentifier: "Cell")
propertyTabel.dataSource = self
propertyTabel.delegate = self
}
didSelectRowAt Function
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let vc = storyboard?.instantiateViewController(withIdentifier: "PropertyDetailsVC") as? PropertyDetailsVC
var dict = arrRes[indexPath.row]
prop.userId = nullToNil(value: dict["user_id"]) as? String
prop.id = nullToNil(value: dict["property_id"]) as? String
prop.code = nullToNil(value: dict["property_code"]) as? String
present(vc!, animated: true, completion: nil)
}
Error Screenshot
Upvotes: 0
Views: 1111
Reputation: 615
Add this code in your didSelect
method
let yourStoryboardObject = UIStoryboard(name: "yourStoryboardName", bundle: nil)
let vc = yourStoryboardObject?.instantiateViewController(withIdentifier: "PropertyDetailsVC") as? PropertyDetailsVC
Upvotes: 3