segue using NSCoder in a selected tableview cell

36 Views Asked by At

In my swift code code the goal is when a user selects a tableview cell it segues to class Expenset. My code cannot use storyboard only code. You can see in a gif below that my code below is not working.

gif

class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
    
    @objc func segueAction(_ coder : NSCoder) -> Expenset? {
        
        
        let vc = Expenset (coder: coder)
        
        
        guard let indexPath = tableveiew.indexPathForSelectedRow else {
            return vc
        }
        
        let budget = budgets[indexPath.row]
        vc?.budget = budget
        
        
        tableveiew.deselectRow(at: indexPath, animated: true)
        
        
        
        return vc
        
        
    }


}


class Expenset : ViewController {
    
    
    var budget : Budget?
 private var expenses : [Any] = []
}
0

There are 0 best solutions below