I am writing an IOS app in Swift.
After navigating to VC, I need to remove all view controllers except current (onscreen) from navigation controller. I am using below code and its working fine. But, it doesn't look optimized solution. Any better solution like syntactic sugar like map, filter, etc:
if let nc = appDelegate().baseNavigationController{
nc.viewControllers = Array(nc.viewControllers.dropLast(nc.viewControllers.count-1)
}