Swift 如何在闭包内使用navigationController?.popViewController(动画:true),且没有警告和错误?

Swift 如何在闭包内使用navigationController?.popViewController(动画:true),且没有警告和错误?,swift,uiviewcontroller,uinavigationcontroller,swift3,closures,Swift,Uiviewcontroller,Uinavigationcontroller,Swift3,Closures,我知道在swift 3中: navigationController?.popViewController(animated: true) 将产生以下警告: "Expression of type "UIViewController?" is unused" 我知道摆脱这一警告的建议方法是: _ = navigationController?.popViewController(animated: true) 但是,当它位于闭合内部时: myFunction(myParams: ["bla

我知道在swift 3中:

navigationController?.popViewController(animated: true)
将产生以下警告:

"Expression of type "UIViewController?" is unused"
我知道摆脱这一警告的建议方法是:

_ = navigationController?.popViewController(animated: true)
但是,当它位于闭合内部时:

myFunction(myParams: ["blah", "bleh"], callback: { myResult in
_ = navigationController?.popViewController(animated: true)
})
我得到这个错误:

Implicit use of 'self' in closure; use 'self.' to make capture semantics explicit
如果我这样做:

myFunction(myParams: ["blah", "bleh"], callback: { myResult in
self.navigationController?.popViewController(animated: true)
})
我又得到了警告:

"Expression of type "UIViewController?" is unused"

如何在闭包中使用navigationController?.popViewController(动画:true)而不出现警告和错误?

您就快到了!它只是结合了您已经生产的产品:

myFunction(myParams: ["blah", "bleh"], callback: { myResult in
    _ = self.navigationController?.popViewController(animated: true)
})

嗯,嗯!!嘘,我快发疯了,谢谢!