Xcode 8 / Swift 3: “Expression of type UIViewController? is unused” warning when pop

Poping view controller from navigation stack does not returns anything. Then also when I have to tried pop view controller, then it gives me warning like :

It is working fine in swift 2.x, So my question is how to pop view controller in swift 3.0 ? Is there any different method to pop view controller or developer have to store return value in any variable for posing view controller ?

Please help me.

The function now has a return type; it returns the view controller which was popped.

You can ignore the result by prefixing that line of code with let _ =, i.e.

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