Unable to retain the selected rows when navigating the UIVIewControllers in swift

45 Views Asked by At

I have two uiviewcontrollers for filter purpose, from the first controller using the button i could present the second view controller, from the second view controller i have a tableview and select their rows and passing those row values to the first view controller. It passes the values good, but i again click the same button of the first controller, like wise previous it opens the second controller but the rows i already selected seem unselected.

sample code: for clicking the First controller button for opening the view controller

    @objc func empFilterButton(_ sender: Any){
        let controller = EmployeeFilterViewController()
        self.navigationController?.pushViewController(controller, animated: true)

    }

sample code: for selecting the rows and pass those values to first view controller

@objc func applyFilter(_ sender: Any){
    let empViewCtrl = EmployeeViewController()
    empViewCtrl.deptIdString = deptIdString
    empViewCtrl.dateIdString = dateIdString
    empViewCtrl.shiftIdString = shiftIdString
    empViewCtrl.locationIdString = locationIdString
    self.navigationController?.pushViewController(empViewCtrl, animated: true)
}
0

There are 0 best solutions below