self.dismiss(animated: true, completion: nil) not working

Hello,


I am trying to use self.dismiss funtion for my app. From the menu button, when clicked on an option, the app goes to new View Controller but from there when I try to close the VC and return to my homeVC using self.dismiss. I am getting an exception. The part of my code is this:


@IBAction func dismissPresssed(_ sender: Any) {

let home = HomeViewController()

//self.dismiss(animated: true, completion: nil)

}


Error Log:


Is5kcfkDB6UqBkHV7cqhpcPSsN13

2019-04-01 10:30:09.575272-0400 CSW_Test[48263:3539293] Unknown class CSWProjectsViewController in Interface Builder file.

2019-04-01 10:30:09.580739-0400 CSW_Test[48263:3539293] Unknown class CSWProjectsViewController in Interface Builder file.

2019-04-01 10:30:09.583127-0400 CSW_Test[48263:3539293] <UITableView: 0x7f930c88a400; frame = (0 0; 335 667); clipsToBounds = YES; autoresize = W+H; gestureRecognizers = <NSArray: 0x600001f58540>; layer = <CALayer: 0x60000114ad00>; contentOffset: {0, -40}; contentSize: {335, 446}; adjustedContentInset: {40, 0, 0, 0}>'s window is not equal to <UINavigationController: 0x7f930c823000>'s view's window!

2019-04-01 10:30:11.651535-0400 CSW_Test[48263:3539293] -[UIViewController dismissPresssed:]: unrecognized selector sent to instance 0x7f930bd4a140

2019-04-01 10:30:11.677318-0400 CSW_Test[48263:3539293] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIViewController dismissPresssed:]: unrecognized selector sent to instance 0x7f930bd4a140'

Replies

Function unwind() usualy is used for return to previous controller.


In your case it looks like you need to indicate sender. Instead "Any" try use "UIButton"