【发布时间】:2016-12-08 15:22:59
【问题描述】:
我知道在 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(animated: true)?
【问题讨论】:
标签: swift uiviewcontroller uinavigationcontroller swift3 closures