Q:

How to display UINavigationController from didSelectRowtAtIndexPath method of UITableViewDelegate?

How to display UINavigationController when a user taps on a table cell? Code only.
The following code doesn't work:
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
    guard let vm = (viewModel as? UICatalogVM)?.modelForRowAtIndexPath(indexPath) else {
        return
    }
    let vc = ActivityIndicatorVC(viewModel: vm)
    let nc = UINavigationController(rootViewController: self)
    nc.pushViewController(vc, animated: true)
}

On the contrary such code works, but it is going to display the VC modally, which is not what I would like to do.
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
    guard let vm = (viewModel as? UICatalogVM)?.modelForRowAtIndexPath(indexPath) else {
        return
    }

    let vc = ActivityIndicatorVC(viewModel: vm)
    self.showViewController(vc, sender: self)
}

A:

If your current view controller is already in a navigation controller then you can directly do it like:
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
    guard let vm = (viewModel as? UICatalogVM)?.modelForRowAtIndexPath(indexPath) else {
        return
    }
    let vc = ActivityIndicatorVC(viewModel: vm)
    navigationController.pushViewController(vc, animated: true)
}

Otherwise you have to add your current view controller in navigation controller before its coming in front.
For example if you are using Storyboard and your current view controller is initial view controller then you have to add a UINavigationController as initial view controller and then set your current view controller as rootViewController for that navigation controller then you can easily push new view controller on didSelectRowAtIndexPath: using 
navigationController.pushViewController(vc, animated: true)

