Delegates do’s and dont’s
1 min readJan 29, 2020
dismiss(animated: true) {
let viewController = someViewController()
self.delegate?.pushViewController(viewController)
}
If you find yourself doing this, don’t!
Note from my team mate:
Ideally the delegate call should be action agnostic — it should be telling whoever the delegate is what happened, not what to do, something like
didSelectThisRow
. Then the delegate can do the dismissing and presenting whatever else is required.A good rule of thumb in these sorts of cases would be that any navigation related stuff should not be in the view controller.