I'm using a navigation view controller that I've made in interface builder to make a side menu function in my app.
The controller titled Menu View Controller is the menu that slides out when the button above "Home" is pressed in the controller titled home (the second one). The Menu View Controller is comprised of a table view and four table view cells, where each menu item is one cell.
In my HomeViewController file I've written a switch statement, where each case is called when its corresponding menu item (table view cell) is pressed:
I am confident that each case is being called appropriately because the print statements are being written in the console when each cell is pressed. As you can see, in the case of ".my_dogs" I've written a constant- the view controller from the storyboard that is on the far right in the first picture. It just has a label constrained to the center.
I believe that this constant is being instantiated properly, as these are the identities of the far right storyboard in the interface builder:
The class "DogsViewController" is just the default swift file (with viewDidLoad() and no code in it).
Now here's the issue: When I comment out the present(dogsViewController, animated: true)
, there is no crash when I tap the "My Dogs" table cell. When I add it, I get the following error:
*** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<Poochtime.DogsViewController 0x7fc60f916620> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key test.'
I've also tried navigationController.pushViewController(dogsViewController, animated: false)
, and this made it so the program did not crash, but it gave me a different functionality that I desire. I need the far right view controller (dogs view controller) to take over the screen when the table cell "My Dogs" is pressed, and I need it to inherit the navigation controller properties like the title (the navigation title is "Home" on the second view controller and the menu button above the title.
To fix this, right-click Main.storyboard and select "Open as > Source Code." This should open up the XML code of the storyboard. From there, Command+F and search for the word "test". If you find a line with this, comment it out. This seems to solve the issue.