Skip to content

Instantly share code, notes, and snippets.

@stami
Created July 13, 2018 06:39
Show Gist options
  • Save stami/849278cca01edbc7dbc529fa07c47de8 to your computer and use it in GitHub Desktop.
Save stami/849278cca01edbc7dbc529fa07c47de8 to your computer and use it in GitHub Desktop.
UINavigationController previousViewController with offset
import UIKit
extension UINavigationController {
func previousViewController(offset: Int = 1) -> UIViewController? {
if viewControllers.count > offset {
return viewControllers[viewControllers.count - 1 - offset]
}
return nil
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment