在swift2.x中 有這個方法
self.navigationController?.popViewController(animated: true)
但是在swift3 就會出現這個警告
屏幕快照 2017-01-17 10.25.38.png
解決辦法為:
_ = self.navigationController?.popViewController(animated: true)
Swift 3 大的改動之一就是所有帶有返回值的函數如果沒有變量去接收返回值,就會報warning。
popViewController和popToRootViewController基本上人人都用,但是有多少人知道這兩個函數其實是有返回值的。
看一下官方的解釋吧
open func popViewController(animated: Bool) -> UIViewController? // Returns the popped controller.
open func popToViewController(_ viewController: UIViewController, animated: Bool) -> [UIViewController]?
// 官方解釋
// Pops view controllers until the one specified is on top. Returns the popped controllers.