Sausage Modulation Matrix Sausage Modulation Matrix - 7 months ago 1788
Swift Question

Xcode 8 / Swift 3: "Expression of type UIViewController? is unused" warning

I've got the following function which compiled cleanly previously but generates a warning with Xcode 8.

func exitViewController()
navigationController?.popViewController(animated: true)

"Expression of type "UIViewController?" is unused".

Why is it saying this and is there a way to remove it?

The code executes as expected.


popViewController(animated:) returns UIViewController?, and the compiler is giving that warning since you aren't capturing the value. The solution is to use let with no name:

let _ = navigationController?.popViewController(animated: true)